Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Sven R. Kunze
don't any way to separate both lists on this command call: cool-script.py thing1 thing2 stuff1 stuff2 Do I miss something here? Best Sven On 03.08.21 01:49, Dan Stromberg wrote: Isn't -- usually used to signal the end of options? On Mon, Aug 2, 2021 at 12:52 PM Sven R. Kunze <mailto:s

argparse: delimiter for argparse list arguments

2021-08-02 Thread Sven R. Kunze
Hi everyone, maybe, I am missing something here but is it possible to specify a delimiter for list arguments in argparse: https://docs.python.org/3/library/argparse.html Usually, '--' is used to separate two lists (cf. git). Cheers, Sven -- https://mail.python.org/mailman/listinfo/python

[issue33972] AttributeError in email.message.iter_attachments()

2018-06-26 Thread Sven Krohlas
New submission from Sven Krohlas : Hello everyone, Today I stumbled over unexpected behaviour when parsing emails with Python 3.5. mail is of type: Traceback (most recent call last): File "XXX", line YYY, in ZZZ for attachment in mail.iter_attachments(): File "/usr/lib/

[issue32049] 2.7.14 does not uninstall cleanly if installation was run as SYSTEM account (SCCM)

2017-11-16 Thread Sven Pagel
New submission from Sven Pagel <niemalsnever-pythonbugtrac...@pcs1990.net>: If I install Python 2.7.14 on Windows (using the MSI) using the SYSTEM account, as is done by SCCM, uninstalling fails to clean up the registry so Python is still showing up as installed in the control panel (and

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-07 Thread Sven Marnach
Sven Marnach added the comment: The current behaviour of islice() seems inconsistent with the rest of Python. All other functions taking start, stop and step arguments like slice(), range() and itertools.count() do accept integer-like objects. The code given as "roughly equiv

Re: [Python-ideas] Inconsistencies

2016-09-11 Thread Sven R. Kunze
t the discussion in better perspective, especially when people here trying to be overly absolute in their views (which was the quote about). Cheers, Sven -- https://mail.python.org/mailman/listinfo/python-list

[issue27598] Add SizedIterable to collections.abc and typing

2016-08-04 Thread Sven R. Kunze
Sven R. Kunze added the comment: I am way too late to the discussion but I also support the term "collections". I think it also helps developers coming from a C# background: https://msdn.microsoft.com/library/92t2ye13(v=vs.110).aspx -- nosy

Re: Best Practices for Internal Package Structure

2016-04-06 Thread Sven R. Kunze
lines to 10 using dict comprehensions" "that's even more readable; +1 line, that's okay" Life is full of compromises. This guideline is more about discussing, shaping existing code and extracting the essence (with yourself or with colleagues) to keep things on a usable level. Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best Practices for Internal Package Structure

2016-04-06 Thread Sven R. Kunze
rkunze/xheap https://github.com/srkunze/fork https://github.com/srkunze/xcache They are small but deserve the same professionalism I daresay. How does PyCharm make the use of many files easier? I'll let Sven answer that one. I don't know, but I've noticed the correlation of habit to IDE. Defi

Re: Best Practices for Internal Package Structure

2016-04-05 Thread Sven R. Kunze
it so I take it with a smile. But it's definitely a wart. So, we have a new guideline since then: "empty __init__.py" if possible of course; you sometimes need to collect/do magic imports but that's a separate matter. Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best Practices for Internal Package Structure

2016-04-05 Thread Sven R. Kunze
On 05.04.2016 19:59, Chris Angelico wrote: On Wed, Apr 6, 2016 at 3:38 AM, Sven R. Kunze <srku...@mail.de> wrote: Your package is currently under 500 lines. As it stands now, you could easily flatten it to a single module: bidict.py I don't recommend this. The line is blurry b

Re: Best Practices for Internal Package Structure

2016-04-05 Thread Sven R. Kunze
to detecting names, we like the direct way. In case of our PyPI module, usability is really important for newbies and people not using sophisticated IDEs. So, making it really easy for them is a must. :) Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best Practices for Internal Package Structure

2016-04-04 Thread Sven R. Kunze
t have some internals that should not be used outside of them. The _ signifies that actually clearly but it looks weird within the package itself. We haven't found a solution so far. Maybe others do. Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-31 Thread Sven R. Kunze
On 31.03.2016 18:30, Travis Griggs wrote: British: http://www.oxforddictionaries.com/definition/english/python American: http://www.dictionary.com/browse/python?s=t That does it. If I ever make some sort of open source module for pythun/pythawn I’ll be sure to call it either

Re: Slice equivalent to dict.get

2016-03-31 Thread Sven R. Kunze
slice. If the slice is out of range, Python returns a empty sequence: I see what you are trying to achieve here. What do you think about this? [1, 2, 3].get(999, '?') Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-30 Thread Sven R. Kunze
On 30.03.2016 12:21, BartC wrote: On 30/03/2016 11:07, Sven R. Kunze wrote: On 30.03.2016 01:29, Eric S. Johansson wrote: On 3/29/2016 6:05 AM, Sven R. Kunze wrote: Python = English As someone who writes English text and code using speech recognition, I can assure you that Python

Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-30 Thread Sven R. Kunze
know how other English-speaking groups say the word, but in England the first syllable is stressed and the second is the conventional short "uh" sound). TJG I recognize this too. I also started with the England variant but now I am not so sure anymore. :D Sven -- https://mail.python.o

Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-30 Thread Sven R. Kunze
On 30.03.2016 01:29, Eric S. Johansson wrote: On 3/29/2016 6:05 AM, Sven R. Kunze wrote: Python = English As someone who writes English text and code using speech recognition, I can assure you that Python is not English. :-) :D Interesting. Never thought of how Python sounds when spoken

Re: Threading is foobared?

2016-03-30 Thread Sven R. Kunze
On 30.03.2016 01:43, Steven D'Aprano wrote: On Tue, 29 Mar 2016 09:26 pm, Sven R. Kunze wrote: On 27.03.2016 05:01, Steven D'Aprano wrote: Am I the only one who has noticed that threading of posts here is severely broken? It's always been the case that there have been a few posts here

Re: [OT] C# -- sharp or carp? was Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Sven R. Kunze
n't get stuck there. Learn something new from time to time; even a new language. Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: [OT] C# -- sharp or carp? was Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Sven R. Kunze
On 29.03.2016 12:18, Sven R. Kunze wrote: On 29.03.2016 11:39, Peter Otten wrote: My question to those who know a bit of C#: what is the state-of-the-art equivalent to "\n".join(foo.description() for foo in mylist if foo.description() != "") U

Re: Exclude every nth element from list?

2016-03-29 Thread Sven R. Kunze
On 26.03.2016 18:06, Peter Otten wrote: beliavsky--- via Python-list wrote: I can use x[::n] to select every nth element of a list. Is there a one-liner to get a list that excludes every nth element? del x[::n] ;) Actually quite nice. -- https://mail.python.org/mailman/listinfo/python-list

Re: Threading is foobared?

2016-03-29 Thread Sven R. Kunze
already have a conversation about this? I thought it is my thunderbird messing things up. Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2016-03-29 Thread Sven R. Kunze
On 28.03.2016 17:34, ast wrote: "Matt Wheeler" <m...@funkyhat.org> a écrit dans le message de news:mailman.92.1458825746.2244.python-l...@python.org... On Thu, 24 Mar 2016 11:10 Sven R. Kunze, <srku...@mail.de> wrote: On 24.03.2016 11:57, Matt Wheeler wrote: >&g

Re: [OT] C# -- sharp or carp? was Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Sven R. Kunze
On 29.03.2016 11:39, Peter Otten wrote: My question to those who know a bit of C#: what is the state-of-the-art equivalent to "\n".join(foo.description() for foo in mylist if foo.description() != "") Using LINQ, I suppose:

Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Sven R. Kunze
On 29.03.2016 06:13, Michael Torrie wrote: On 03/28/2016 06:44 PM, Steven D'Aprano wrote: http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/ I have the same problem as the writer. Working in Python makes me really dislike working in any other

Re: Which are best, well-tested ways to create REST services, with Json, in Python?

2016-03-29 Thread Sven R. Kunze
Not heard of any but I can recommend django-restframework. We've got good experience with that. On 28.03.2016 23:06, David Shi via Python-list wrote: Has anyone done a recent reviews of creating REST services, in Python? Regards. David -- https://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2016-03-24 Thread Sven R. Kunze
On 24.03.2016 14:22, Matt Wheeler wrote: On Thu, 24 Mar 2016 11:10 Sven R. Kunze, <srku...@mail.de> 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

Re: newbie question

2016-03-24 Thread Sven R. Kunze
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

Re: monkey patching __code__

2016-03-23 Thread Sven R. Kunze
ct" -- 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

how to cache invalidation

2016-03-22 Thread Sven R. Kunze
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

Re: monkey patching __code__

2016-03-22 Thread Sven R. Kunze
On 21.03.2016 21:42, Matt Wheeler wrote: On 20 March 2016 at 16:46, Sven R. Kunze <srku...@mail.de> 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 you

Re: monkey patching __code__

2016-03-20 Thread Sven R. Kunze
d 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

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
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 "else&quo

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
ld 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

Re: monkey patching __code__

2016-03-19 Thread Sven R. Kunze
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

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
ks. :-) 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

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
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

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
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

Re: monkey patching __code__

2016-03-19 Thread Sven R. Kunze
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

Re: Replace weird error message?

2016-03-19 Thread Sven R. Kunze
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 . For example a hint that "0" does work for the given argument.

Re: monkey patching __code__

2016-03-19 Thread Sven R. Kunze
eplace the function'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

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
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 collecti

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
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

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
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 function

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
. Thanks. :) Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
) if empty: something_else() Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: empty clause of for loops

2016-03-19 Thread Sven R. Kunze
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 describe

Re: empty clause of for loops

2016-03-18 Thread Sven R. Kunze
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.

Re: monkey patching __code__

2016-03-18 Thread Sven R. Kunze
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 <ian.g.ke...@gmail.com> wrote: Your patched version takes two extra arguments. Did you add the defaults for those to the function's __defaults__ att

Re: empty clause of for loops

2016-03-18 Thread Sven R. Kunze
nd 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

Re: Bash-like pipes in Python

2016-03-18 Thread Sven R. Kunze
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

monkey patching __code__

2016-03-18 Thread Sven R. Kunze
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

Re: empty clause of for loops

2016-03-16 Thread Sven R. Kunze
. It's furthermore too large to fit into memory completely. Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

empty clause of for loops

2016-03-16 Thread Sven R. Kunze
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

Re: argparse

2016-03-12 Thread Sven R. Kunze
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

Re: even faster heaps

2016-03-09 Thread Sven R. Kunze
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

Re: even faster heaps

2016-03-09 Thread Sven R. Kunze
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. A

Re: even faster heaps

2016-03-09 Thread Sven R. Kunze
. :) But you are right. I re-executed the benchmark and compared 100, 1000 and 1 with each other. Almost no difference at all. I am going to reduce it to 100. So, it takes ca. 8 minutes on my machine. Thanks for your feedback, Sven On Sun, Mar 6, 2016 at 7:29 PM, Sven R. Kunze <s

Re: reversed(zip(...)) not working as intended

2016-03-06 Thread Sven R. Kunze
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

Re: reversed(zip(...)) not working as intended

2016-03-06 Thread Sven R. Kunze
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 from

reversed(zip(...)) not working as intended

2016-03-06 Thread Sven R. Kunze
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

even faster heaps

2016-03-06 Thread Sven R. Kunze
eedups: 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

Re: [Off-topic] Requests author discusses MentalHealthError exception

2016-03-01 Thread Sven R. Kunze
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

Re: Everything good about Python except GUI IDE?

2016-02-28 Thread Sven R. Kunze
an 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 quite ugly and it has this "distinct compil

Re: Bug in Python?

2016-02-28 Thread Sven R. Kunze
ut there. Propose that on the tracker, after checking previous issues. :) Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: Bug in Python?

2016-02-28 Thread Sven R. Kunze
On 27.02.2016 00:07, eryk sun wrote: On Fri, Feb 26, 2016 at 4:08 PM, Sven R. Kunze <srku...@mail.de> 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 woul

Re: Bug in Python?

2016-02-28 Thread Sven R. Kunze
On 26.02.2016 23:37, Ian Kelly wrote: On Fri, Feb 26, 2016 at 3:08 PM, Sven R. Kunze <srku...@mail.de> 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,

Bug in Python?

2016-02-26 Thread Sven R. Kunze
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.python.org

Re: How the heck does async/await work in Python 3.5

2016-02-23 Thread Sven R. Kunze
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

Re: How the heck does async/await work in Python 3.5

2016-02-23 Thread Sven R. Kunze
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

Re: How the heck does async/await work in Python 3.5

2016-02-23 Thread Sven R. Kunze
On 23.02.2016 01:48, Ian Kelly wrote: On Mon, Feb 22, 2016 at 3:16 PM, Sven R. Kunze <srku...@mail.de> 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_un

Re: How the heck does async/await work in Python 3.5

2016-02-22 Thread Sven R. Kunze
ync def) Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

benchmarking in general and using xheap

2016-02-19 Thread Sven R. Kunze
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

Re: Guido on python3 for beginners

2016-02-18 Thread Sven R. Kunze
y less steep. I think py3 has more 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/li

Re: Multiple Assignment a = b = c

2016-02-16 Thread Sven R. Kunze
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

Re: Multiple Assignment a = b = c

2016-02-16 Thread Sven R. Kunze
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

Re: Asyncio thought experiment

2016-02-10 Thread Sven R. Kunze
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: blocking statements do

Re: Heap Implementation

2016-02-10 Thread Sven R. Kunze
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

Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze
do better here? Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze
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,

Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze
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. Competitive

Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze
ght when posting to the mailing list. sorry for that. Competitive programming? That sounds interesting. :) Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: _siftup and _siftdown implementation

2016-02-04 Thread Sven R. Kunze
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

Re: Efficient Wrappers for Instance Methods

2016-02-04 Thread Sven R. Kunze
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 from

Re: Efficient Wrappers for Instance Methods

2016-02-04 Thread Sven R. Kunze
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 keep

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
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.python.o

Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
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

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
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. :) --

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
. Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
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

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
ethod when the function I am wrapping actually already has the same signature? Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
don't know. I appreciate every single reply. :) Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

Re: Heap Implementation

2016-02-02 Thread Sven R. Kunze
On 02.02.2016 01:48, srinivas devaki wrote: On Feb 1, 2016 10:54 PM, "Sven R. Kunze" <srku...@mail.de <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 xhe

Re: Heap Implementation

2016-02-01 Thread Sven R. Kunze
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.Timer('for _

Re: Heap Implementation

2016-02-01 Thread Sven R. Kunze
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 sweeping

Re: psss...I want to move from Perl to Python

2016-01-30 Thread Sven R. Kunze
On 29.01.2016 23:49, Ben Finney wrote: "Sven R. Kunze" <srku...@mail.de> 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 i

Heap Implemenation

2016-01-30 Thread Sven R. Kunze
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 -- https

Heap Implementation

2016-01-30 Thread Sven R. Kunze
/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

Re: psss...I want to move from Perl to Python

2016-01-29 Thread Sven R. Kunze
I be aware of? Don't worry. Just try it out. :) Best, Sven -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   >