Set & Frozenset?
Matt Nordhoff
mnordhoff at mattnordhoff.com
Mon Mar 9 13:40:35 EDT 2009
Alan G Isaac wrote:
>> Hans Larsen schrieb:
>>> How could I "take" an elemment from a set or a frozenset
>
>
> On 3/8/2009 2:06 PM Diez B. Roggisch apparently wrote:
>> You iterate over them. If you only want one value, use
>> iter(the_set).next()
>
>
> I recall a claim that
>
> for result in myset: break
>
> is the most efficient way to get one result.
> Is this right? (It seems nearly the same.)
>
> Alan Isaac
Checking Python 2.5 on Linux, your solution is much faster, but seeing
as they both come in under a microsecond, it hardly matters.
--
More information about the Python-list
mailing list