[Python-Dev] Retrieve an arbitrary element from a set without removing it
Terry Reedy
tjreedy at udel.edu
Sun Oct 25 07:50:06 CET 2009
Alex Martelli wrote:
> Next(s) would seem good...
That does not work. It has to be next(iter(s)), and that has been tried
and eliminated because it is significantly slower.
>> 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"
More information about the Python-Dev
mailing list