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 the loop."

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to