Set & Frozenset?
tjreedy at udel.edu
Tue Mar 10 20:15:19 CET 2009
Lie Ryan wrote:
>>> I recall a claim that
>>> for result in myset: break
>>> is the most efficient way to get one result.
> I'd never expect that for-loop assignment is even faster than a
> precreated iter object (the second test)... but I don't think this
> for-looping variable leaking behavior is guaranteed, isn't it?
It is an intentional, documented feature:
"Names in the target list are not deleted when the loop is finished, but
if the sequence is empty, it will not have been assigned to at all by
More information about the Python-list