[Python-Dev] PEP-646 question: unpacking into single Generic parameter

2021-09-24 Thread willi
le[[*Tuple[int, Ts]]], *args: *Ts): f(*enumerate(args)) ``` In particular I'm talking about the `*Tuple[int, Ts]` syntax. All the examples from the PEP use `*Ts` so I don't know if this is legal, but I hope so. This should probably be clarified in the PEP. -- Best regard

[Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-23 Thread Willi Richert
Hi, recently I wrote an algorithm, in which very often I had to get an arbitrary element from a set without removing it. Three possibilities came to mind: 1. x = some_set.pop() some_set.add(x) 2. for x in some_set: break 3. x = iter(some_set).next() Of course, the third should be

[Python-Dev] First shot at some_set.get()

2009-10-23 Thread Willi Richert
Hi, here is the first shot to provide a faster means of retrieving an arbitrary element from a set without removing it. The times for = from timeit import * stat1 = "for i in xrange(100): iter(s).next()" stat2 = "for i in xrange(100): s.get()" for stat in [stat1, stat

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-23 Thread Willi Richert
nts, especially to Stefan for the http://comments.gmane.org/gmane.comp.python.ideas/5606 link. Regards, wr Am Freitag, 23. Oktober 2009 19:25:48 schrieb John Arbash Meinel: > Vitor Bosshard wrote: > > 2009/10/23 Willi Richert : > >> Hi, > >> > >> recently I w

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Willi Richert
ag, 24. Oktober 2009 00:49:38 schrieb Steven D'Aprano: > On Sat, 24 Oct 2009 07:53:24 am Willi Richert wrote: > > Hi, > > > > surprised about the performance of for/break provided by Vitor, I did > > some more testing. It revealed that indeed we can forget the get() &g

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Willi Richert
or for i in xrange(1000): s.get() : 0.148580 Time for g=s.get; for i in xrange(1000): g() :0.080563 So, now set.get() is indeed the fastest and preferable solution if you need massive amounts of retrieving elements from a set without removing them. wr Am Freitag, 23. O

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-26 Thread Willi Richert
Hi, I totally agree regarding the efficiency. Code that relies on a fast "non- removing .pop()" probably has other worse bottlenecks that should be targetted first. This would, however, relief every programmer who needs this the first time in his Python experience, to research how this could be

Re: [Python-Dev] Retrieve an arbitrary element from a set withoutremoving it

2009-10-26 Thread Willi Richert
For those of you who want to tinker with it, I posted the patch against the current trunk at http://bugs.python.org/issue7212 Have fun, wr Am Montag, 26. Oktober 2009 21:32:32 schrieb Guido van Rossum: > On Mon, Oct 26, 2009 at 1:19 PM, Antoine Pitrou wrote: > > Jesse Noller gmail.com> writes:

Re: [Python-Dev] Retrieve an arbitrary element from a set withoutremoving it

2009-10-30 Thread Willi Richert
ove(el) > y = set.get() > > there are no guarantees about x and y being different. > > I believe that the patch supplied by Willi Richart implemented these > behaviours. > > http://bugs.python.org/issue7212 > Actually, no. The patch makes no assumption a

Re: [Python-Dev] Retrieve an arbitrary element from a setwithoutremoving it

2009-11-01 Thread Willi Richert
Am Sonntag, 1. November 2009 12:21:15 schrieben Sie: > It seems that even those originally asking for set retrieval have gone > silent Nope. Stilll following and waiting for the verdict of the community after having filed the corpus delicti [1] wr [1]: http://bugs.python.org/issue7212 __

Re: [Python-Dev] Retrieve an arbitrary element from a set withoutremoving it

2009-11-02 Thread Willi Richert
Hi, all your points are valid -- for the experienced Python programmer who has stumbled across this issue already and solved it in one of several ways. All your points, however, do not support the "one obvious way to do it" philosophy of Python. It's all about making Python even more clean and