Rene Pijlman <[EMAIL PROTECTED]> wrote:
> Peter Otten:
> >>>> s = set(["one-and-only"])
> >>>> item, = s
   ...
> >The comma may easily be missed, though.
> 
> You could write:
> 
>     (item,) = s
> 
> But I'm not sure if this introduces additional overhead.

Naah...:

helen:~ alex$ python -mtimeit -s's=set([23])' 'x,=s'         
1000000 loops, best of 3: 0.689 usec per loop
helen:~ alex$ python -mtimeit -s's=set([23])' '(x,)=s'
1000000 loops, best of 3: 0.652 usec per loop
helen:~ alex$ python -mtimeit -s's=set([23])' '[x]=s'
1000000 loops, best of 3: 0.651 usec per loop

...much of a muchness.


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

Reply via email to