[Python-Dev] Retrieve an arbitrary element from a set without removing it (original) (raw)
Alex Martelli aleaxit at gmail.com
Sun Oct 25 05:22:03 CET 2009
- Previous message: [Python-Dev] Retrieve an arbitrary element from a set without removing it
- Next message: [Python-Dev] Retrieve an arbitrary element from a set without removing it
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Next(s) would seem good...
Alex
Sent from my iPhone
On Oct 24, 2009, at 6:47 PM, John Arbash Meinel <john.meinel at canonical.com
wrote:
Adam Olsen wrote:
On Fri, Oct 23, 2009 at 11:04, Vitor Bosshard <algorias at gmail.com> wrote:
I see this as being useful for frozensets as well, where you can't get an arbitrary element easily due to the obvious lack of .pop(). I ran into this recently, when I had a frozenset that I knew had 1 element (it was the difference between 2 other sets), but couldn't get to that element easily (get the pun?)
item, = setofone
Interesting. It depends a bit on the speed of tuple unpacking, but presumably that is quite fast. On my system it is pretty darn good: 0.101us "for x in s: break" 0.112us "x, = s" 0.122us "for x in s: pass" So not quite as good as the for loop, but quite close. John =:->
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/aleaxit%40gmail.com
- Previous message: [Python-Dev] Retrieve an arbitrary element from a set without removing it
- Next message: [Python-Dev] Retrieve an arbitrary element from a set without removing it
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]