On 09.01.2016 19:32, Paul Rubin wrote:
"Sven R. Kunze" writes:
Basically a task scheduler where tasks can be thrown away once they
are too long in the queue.
I don't think there's a real nice way to do this with heapq. The
computer-sciencey way would involve separate bala
ex" and be efficient at it (by
not using _heapq C implementation).
So, I thought I did another wrapper. ;) It at least uses _heapq (if
available otherwise heapq) and lets you remove items without violating
the invariant in O(log n). I am going to make that open-source on pypi
and see what p
On 13.01.2016 12:20, Cem Karan wrote:
On Jan 12, 2016, at 11:18 AM, "Sven R. Kunze" wrote:
Thanks for replying here. I've come across these types of
wrappers/re-implementations of heapq as well when researching this issue. :)
Unfortunately, they don't solve the unde
Hi Gert,
just upgrade to 5.03.
Best,
Sven
On 13.01.2016 18:38, Gert Förster wrote:
Ladies, Gentlemen,
using the PyCharm Community Edition 4.5.4, with Python-3-5-1-amd64.exe,
there is constantly a “Repair”-demand. This is “successful” when executed.
Without execution, there results an “Error
e aware of?
Don't worry. Just try it out. :)
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 29.01.2016 23:49, Ben Finney wrote:
"Sven R. Kunze" writes:
On 29.01.2016 01:01, Fillmore wrote:
How was the Python 2.7 vs Python 3.X solved? which version should I
go for?
Python 3 is the new and better one.
More importantly: Python 2 will never improve; Python 3 is the onl
l for your feedback as you have first-hand
experience with heaps.
@srinivas
You might want to have a look at the removal implementation. Do you
think it would be wiser/faster to switch for the sweeping approach?
I plan to publish some benchmarks to compare heapq and xheap.
Best,
Sven
--
s the best/standardized tool in Python to perform benchmarking?
Right now, I use a self-made combo of unittest.TestCase and time.time +
proper formatting.
Best,
Sven
PS: fixing some weird typos and added missing part.
--
https://mail.python.org/mailman/listinfo/python-list
On 31.01.2016 05:59, srinivas devaki wrote:
@Sven
actually you are not sweeping at all, as i remember from my last post
what i meant by sweeping is periodically deleting the elements which
were marked as popped items.
Exactly.
Maybe I didn't express myself well. Would you prefer the swe
On 31.01.2016 02:48, Steven D'Aprano wrote:
On Sunday 31 January 2016 09:47, Sven R. Kunze wrote:
@all
What's the best/standardized tool in Python to perform benchmarking?
timeit
Thanks, Steven.
Maybe, I am doing it wrong but I get some weird results:
>>> min(timeit.Ti
On 02.02.2016 01:48, srinivas devaki wrote:
On Feb 1, 2016 10:54 PM, "Sven R. Kunze" <mailto:srku...@mail.de>> wrote:
>
> Maybe I didn't express myself well. Would you prefer the sweeping
approach in terms of efficiency over how I implemented xheap currently?
&g
ethod from a function like I aliased
replace with poppush?
If I am not completely mistaken, it saves 1 stack frame, right?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
ethod when the
function I am wrapping actually already has the same signature?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
When you call x.replace(2) you are calling heapreplace(2), NOT
heapreplace(self, 2).
It is exactly as you've described it.
Question now is how can I circumvent/shortcut that? There are several
proposals out there in the Web but none of them works. :-/
Best,
Sven
--
https://mail.pyt
er, I don't
know.
I appreciate every single reply. :)
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 03.02.2016 22:19, Peter Otten wrote:
You could try putting
self.heappush = functools.partial(heapq.heappush, self)
into the initializer.
Actually a nice idea if there were no overhead of creating methods for
all heap instances separately. I'll keep that in mind. :)
--
https://mail.pytho
ethod-like.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 03.02.2016 22:34, Bernardo Sulzbach wrote:
Did Peter's suggestion work?
Somewhat for a single Heap class.
However, it breaks inheritance.
--
https://mail.python.org/mailman/listinfo/python-list
On 04.02.2016 00:47, Random832 wrote:
On Wed, Feb 3, 2016, at 16:43, Sven R. Kunze wrote:
Actually a nice idea if there were no overhead of creating methods for
all heap instances separately. I'll keep that in mind. :)
What about changing the class of the object to one which is inherited
On 04.02.2016 19:35, Random832 wrote:
On Thu, Feb 4, 2016, at 11:18, Sven R. Kunze wrote:
On 04.02.2016 00:47, Random832 wrote:
On Wed, Feb 3, 2016, at 16:43, Sven R. Kunze wrote:
Actually a nice idea if there were no overhead of creating methods for
all heap instances separately. I'll
On 05.02.2016 01:12, Steven D'Aprano wrote:
On Fri, 5 Feb 2016 07:50 am, srinivas devaki wrote:
_siftdown function breaks out of the loop when the current pos has a valid
parent.
but _siftup function is not implemented in that fashion, if a valid
subheap is given to the _siftup, it will bring
#x27;t give much thought when posting to
the mailing list. sorry for that.
Competitive programming? That sounds interesting. :)
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 05.02.2016 15:48, Bernardo Sulzbach wrote:
On 02/05/2016 12:42 PM, Sven R. Kunze wrote:
PS: I do competitive programming, I use these modules every couple of
days
when compared to other modules. so didn't give much thought when
posting to
the mailing list. sorry for that.
Compet
do better here?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
r i in range(n)]
random.shuffle(items)
heap = RemovalHeap(items)
random.shuffle(items)
for i in items:
heap.remove(i)
print(X.c)
X.c = 0
(note to myself: never copy PyCharm formatting strings to this list).
On 05.02.2016 17:27, Sven R. Kunze wrote:
Hi srinivas,
er fall victim to
the cascading async/await.
And if you did that, why bother sprinkling async's and await's
everywhere? Why not make every single function call an await implicitly
and every single subroutine an async? In fact, that's how everything
works in multithreading: blockin
. Would you accept a solution that would involve wrapping the
function in another object carrying the priority? Would you prefer a
wrapper that's defined by xheap itself so you can just use it?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
rms a swap operation???
I just want to get a better idea around this.
I think the tuple assignment you showed basically nails it.
First, the rhs is evaluated.
Second, the lhs is evaluated from left to right.
Completely wrong?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 16.02.2016 14:05, Sven R. Kunze wrote:
Hi Srinivas,
I think the tuple assignment you showed basically nails it.
First, the rhs is evaluated.
Second, the lhs is evaluated from left to right.
Completely wrong?
Best,
Sven
As you mentioned swapping. The following two statements do the same
e learning curve because it uses iterators in places
where py2 uses lists. That's a significant new concept and it can be
bug-prone even for programmers who are experienced with it.
That is indeed very true.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
icial infrastructure (tools,
classes, ... such as there is for unittests) around timeit to
encapsulate benchmarks, choosing a baseline, calculate ratios etc (and
write code instead of strings).
Does somebody have an idea here?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
ync def)
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 23.02.2016 01:48, Ian Kelly wrote:
On Mon, Feb 22, 2016 at 3:16 PM, Sven R. Kunze wrote:
Is something like shown in 12:50 ( cout << tcp_reader(1000).get() ) possible
with asyncio? (tcp_reader would be async def)
loop = asyncio.get_event_loop()
print(loop.run_until_complete(tcp_reade
hat that is.
You could wrap up the boilerplate in Python if you like:
def get(coro, loop=None):
if loop is None:
loop = asyncio.get_event_loop()
return loop.run_until_complete(coro)
print(get(tcp_reader(1000)))
As usual. :)
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
Some even suggested putting the table into the Python docs. I am unaware
of the formal procedure here but I would be glad if somebody could point
be at the right direction if that the survey table is wanted in the docs.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
p
def my_heappop(heap):
lastelt = heap.pop()
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)# that's C
return returnitem
return lastelt
ml = MyList(range(10))
my_heappop(ml)
print(ml.count) # print 6
Best,
Sven
--
https://mail.
On 26.02.2016 23:37, Ian Kelly wrote:
On Fri, Feb 26, 2016 at 3:08 PM, Sven R. Kunze wrote:
Python sometimes seems not to hop back and forth between C and Python code.
C code as a rule tends to ignore dunder methods. Those are used to
implement Python operations, not C operations.
Ah, good
On 27.02.2016 00:07, eryk sun wrote:
On Fri, Feb 26, 2016 at 4:08 PM, Sven R. Kunze wrote:
Python sometimes seems not to hop back and forth between C and Python code.
Can somebody explain this?
Normally a C extension would call PySequence_SetItem, which would call
the type's sq_ass
tions out there.
Propose that on the tracker, after checking previous issues.
:)
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
ecause almost
everybody is able to see them and can start having an opinion about them:
Who loves the new Windows modern UI? Either you like it or you hate it.
What about the Riemann zeta function? Anybody?
Best,
Sven
PS: another thought.
I recently introduced LaTeX to my girlfriend. LaTeX is
On 01.03.2016 13:13, Steven D'Aprano wrote:
On Tue, 1 Mar 2016 09:38 am, Larry Martell wrote:
But what is reality?
Reality is that which, when you stop believing in it, doesn't go away.
Just like that.
--
https://mail.python.org/mailman/listinfo/python-list
see huge speedups: from 50x/25x down to 3x/2x compared to heapq. That's
a massive improvement. I will publish an update soon.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
Hi,
what's the reason that reversed(zip(...)) raises as a TypeError?
Would allowing reversed to handle zip and related functions lead to
strange errors?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 06.03.2016 19:53, Peter Otten wrote:
Sven R. Kunze wrote:
what's the reason that reversed(zip(...)) raises as a TypeError?
Would allowing reversed to handle zip and related functions lead to
strange errors?
In Python 3 zip() can deal with infinite iterables -- what would you expect
some unittests and
I love SHORT oneliners:
for c in reversed(zip(ascii_lowercase, ascii_uppercase)):
...
ooops. :-/
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
.80x) 4.41 (
0.78x) 43.86 ( 0.77x)')
So as the results are not much effected apart of __init__, i think you
should consider this.
Looks promising. I will
On 06.03.2016 14:59, Sven R. Kunze wrote:
Using the original xheap benchmark
<http://srkunze.blogspot.de/2016/02/the-xheap-benchmark.html>, I could
see huge speedups: from 50x/25x down to 3x/2x compared to heapq.
That's a massive improvement. I will publish an update soon.
An
On 09.03.2016 19:19, Sven R. Kunze wrote:
ps: there are two error's when i ran tests with test_xheap.
Damn. I see this is Python 2 and Python 3 related. Thanks for bringing
this to my attention. I am going to fix this soon.
Fixed.
--
https://mail.python.org/mailman/listinfo/python-list
e doc string of a function basically is the help string which is true
for arguments as well.
I hope that helps even though you asked for argparse explicitly. :-)
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
Hi,
a colleague of mine (I write this mail because I am on the list) has the
following issue:
for x in my_iterable:
# do
empty:
# do something else
What's the most Pythonic way of doing this?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
tored.
It's furthermore too large to fit into memory completely.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
prefix=None, current_app=None, get=None, fragment=None):
def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None,
current_app=None):
Some ideas?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 16.03.2016 16:09, Joel Goldstick wrote:
symbol '|' in python. Can you elaborate
bitwise or
--
https://mail.python.org/mailman/listinfo/python-list
for...else to work right and I didn't
understand why until finally the penny dropped and realised that "else"
should be called "then".
That's actually a fine idea. One could even say: "finally".
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 18.03.2016 15:33, Sven R. Kunze wrote:
On 18.03.2016 15:23, Ian Kelly wrote:
On Fri, Mar 18, 2016 at 7:47 AM, Ian Kelly
wrote:
Your patched version takes two extra arguments. Did you add the
defaults for those to the function's __defaults__ attribute?
And as an afterthought, you'
On 16.03.2016 17:56, Sven R. Kunze wrote:
On 16.03.2016 17:37, Random832 wrote:
On Wed, Mar 16, 2016, at 11:17, Sven R. Kunze wrote:
I can imagine that. Could you describe the general use-case? From
what I
know, "else" is executed when you don't "break" the loop. W
On 16.03.2016 17:20, Terry Reedy wrote:
On 3/16/2016 11:17 AM, Sven R. Kunze wrote:
On 16.03.2016 16:02, Tim Chase wrote:
Does it annoy me when I have to work in other languages that lack
Python's {for/while}/else functionality? You bet.
I can imagine that. Could you describ
o_something(x)
if empty:
something_else()
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
meant. Thanks. :)
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 16.03.2016 15:29, Sven R. Kunze wrote:
On 16.03.2016 13:57, Peter Otten wrote:
I'd put that the other way round: syntactical support for every pattern
would make for a rather unwieldy language. You have to choose
carefully, and
this requirement could easily be fulfilled by a fun
the first loop.
I think I can imagine where this is coming from but this was not the
initial use-case. I think Tim's answer (count approach) would provide a
solution for this (from my point of view) rather rare use-case.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 16.03.2016 17:37, Random832 wrote:
On Wed, Mar 16, 2016, at 11:17, Sven R. Kunze wrote:
I can imagine that. Could you describe the general use-case? From what I
know, "else" is executed when you don't "break" the loop. When is this
useful?
for item in col
7;s
__globals__ with your own as well.
Thanks again. :-)
Again, why would it make sense for those dunder attributes to be part of
the function but not of the code object?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 16.03.2016 19:53, Ben Finney wrote:
Do you think some better error message should be used?
Yes, I think that error message needs to be improved. Please file a bug
report in Python's issue tracker https://bugs.python.org/>.
For example a hint that "0" does work for the given argument.
I sug
w function that uses the same code but with
different defaults or globals.
It occurred to me after I sent that email.
However, changing globals is not possible.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
ke use of the "-else" clause, I was disappointed I couldn't.
I find the addition to for-loop as useful as we already have a quite
complex try-except-else-finally clause. I don't know why for-loops
couldn't benefit from this as well.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 18.03.2016 20:10, Palpandi wrote:
You can do like this.
if not my_iterable:
for x in my_iterable:
Thanks for you help here, however as already pointed out, my_iterable is
not necessarily a list but more likely an exhaustible iterator/generator.
Best,
Sven
--
https
ch. Thanks. :-)
Although, I for one would like a keyword. I remember having this issue
myself, and found that the "empty" variable approach is more like a
pattern. As usual, patterns are workarounds for features that a language
misses.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
onsidering that Django provides an {% url %} template tag which would
then use yet another reverse implementation.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
quite regularly could find this
useful within the logic part (the actions) of our applications.
Do you think this would be worth posting on python-ideas?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 16.03.2016 16:02, Tim Chase wrote:
On 2016-03-16 15:29, Sven R. Kunze wrote:
I would re-use the "for-else" for this. Everything I thought I
could make use of the "-else" clause, I was disappointed I couldn't.
Hmm...this must be a mind-set thing. I use the "els
;d end up having to do it to lots of modules...
Why do you consider it cleaner?
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 21.03.2016 21:42, Matt Wheeler wrote:
On 20 March 2016 at 16:46, Sven R. Kunze wrote:
On 19.03.2016 00:58, Matt Wheeler wrote:
I know you have a working solution now with updating the code &
defaults of the function, but what about just injecting your function
into the modules that
and extended this to context managers for other purposes. Maybe, it can
be useful to other Python devs as well. :-)
Let me know if you need help with it.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
t;function object" -- and lose the possibility to completely
change the function object in place.
Exactly. Except __globals__ we are all set and I think that'll work for
us. I will report once we've implemented it that way.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 24.03.2016 11:57, Matt Wheeler wrote:
import ast
s = "(1, 2, 3, 4)"
t = ast.literal_eval(s)
t
(1, 2, 3, 4)
I suppose that's the better solution in terms of safety.
--
https://mail.python.org/mailman/listinfo/python-list
On 24.03.2016 14:22, Matt Wheeler wrote:
On Thu, 24 Mar 2016 11:10 Sven R. Kunze, wrote:
On 24.03.2016 11:57, Matt Wheeler wrote:
import ast
s = "(1, 2, 3, 4)"
t = ast.literal_eval(s)
t
(1, 2, 3, 4)
I suppose that's the better solution in terms of safety.
It has the added
xies from before the try: might raise exceptions which in turn might
be caught inside the try: by the wrong exception handler.
Best,
Sven
PS: I already looked into the source of CPython and discovered these places:
https://github.com/python/cpython/blob/d95bb1adefc7/Python/symtable.c#L947
Unfortunately, no. :(
It should work out of the box with no "let me replace all my try-except
statements in my 10 million line code base".
On 12.08.2015 17:32, Ian Kelly wrote:
On Tue, Aug 11, 2015 at 3:47 PM, Sven R. Kunze wrote:
is there something like a hook that a Python mo
On 12.08.2015 18:11, Chris Angelico wrote:
On Thu, Aug 13, 2015 at 2:05 AM, Sven R. Kunze wrote:
Unfortunately, no. :(
It should work out of the box with no "let me replace all my try-except
statements in my 10 million line code base".
(Please don't top-post.)
Is this so
On 13.08.2015 02:45, Chris Angelico wrote:
On Thu, Aug 13, 2015 at 6:54 AM, Mark Lawrence wrote:
On 12/08/2015 19:44, Sven R. Kunze wrote:
On 12.08.2015 18:11, Chris Angelico wrote:
(Please don't top-post.)
Is this some guideline? I actually quite dislike pick somebody's mail to
On 12.08.2015 20:44, Sven R. Kunze wrote:
On 12.08.2015 18:11, Chris Angelico wrote:
Sounds to me like you want some sort of AST transform, possibly in an
import hook. Check out something like MacroPy for an idea of how
powerful this sort of thing can be.
Sounds like I MacroPy would enable me
Am 14-Aug-2015 03:00:05 +0200 schrieb torr...@gmail.com:
> But I digress. We get sidetracked rather easily around here.
You don't say. ;)
-
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UN
run (here, a simple test
case), i.e. also affecting the import/exec of the module __main__.
Hook: https://github.com/srkunze/fork/blob/2e7ecd4b0a/fork.py#L429
Dirty Magic to get things running:
https://github.com/srkunze/fork/blob/2e7ecd4b0a/fork.py#L425
Best,
Sven
--
https://mail.python.org
already have a discussion on python-ideas where we collected many
many aspects on this particular subject.
The results so far:
https://mail.python.org/pipermail/python-ideas/2015-July/034813.html
I know the table is a bit screwed but you will be able to handle that.
Do you have anything you
Hey Victor,
for proper parsing into native Python types, I would recommend YAML.
Also also supports (besides int vs. float) dates and datetimes.
Cheers,
Sven
On 28.08.2015 07:04, Victor Hooi wrote:
Actually, I've just realised, if I just test for numeric or try to cast to
ints, this
28.08.2015 um 18:09 schrieb Sven R. Kunze:
>> I'm reading JSON output from an input file, and extracting values.
>
for proper parsing into native Python types, I would recommend YAML.
"What's the best way to get from A to B?"
"I recommend starting at C."
- E
I agree as well. First evaluate the right side, then assign it to the
left side at once.
On 02.09.2015 12:22, Nick Sarbicki wrote:
That's interesting. I agree with you, I'd prefer the second result in
both cases.
But makes sense as it evaluates left to right and seems to break up
the unpacki
really an over-regulation and very annoying from my point of view.
It reflects the collective experience of programmers, computer
scientists, and so forth of the last decades.
Globals are evil. Stay away from them.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
ak of backwards
compatibility. :/
So, what I take away from this thread right now is that one should avoid
this type of construction whenever possible as long as Python handles it
that way.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
= "Ce programme vous dit bonjour",
executables = [Executable("salut.py")],# <--- HERE
)
I know of several projects having this convention because when using a
repository software like git, it leads to smaller and thus more readable
diffs.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 03.09.2015 00:25, t...@freenet.de wrote:
It is the good idea of Python about modules which are singletons
and therefore have already its state (so in some way they are already somehow
like classes - except the bad annoying thing with the "global" statement).
So, what you really want is a bet
des may have side-effects, but at least independently from each
other. That's at least how I feel about it.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
r side are
unavoidable.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
Please lay OO and sharing globals aside.
It is really about procedural programming and "global"-keyword only.
That said I will really give no longer any comments about this.
That is sad. :(
I at least would like to know if my suggestion would help? :)
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
ination necessary.
With this post, I would like raise awareness of the people in charge of
the Python infrastructure.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
s "wild-west" tree in our source as well but we
moved on to a properly structured tree and it solved problems we didn't
even imagine to have solved when starting this effort some years ago.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
On 09.09.2015 19:55, Steven D'Aprano wrote:
On Wed, 9 Sep 2015 11:09 am, Mario Figueiredo wrote:
You know, it is a pointless exercise to try and downplay programming
languages (any programming language) that has proven its worth by being
generally adopted by the programming community. Adoption
ional than Haskell, and
compiles to lower level code than C does. The compiler's/interpreter's
internals are a bug-free demonstration of utter code beauty, and you
no longer have reason to use any other programming language, because
this one is the ultimate.
That sounds boring, right? ;)
ng and
jeering and throwing things at me?
Probably. ;)
But it it solve a problem, why not.
Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list
101 - 200 of 223 matches
Mail list logo