On Thu, 2010-08-19 at 00:12 +0200, Thomas Jollans wrote:
> On Wednesday 18 August 2010, it occurred to John Nagle to exclaim:
> > On 8/18/2010 11:24 AM, ernest wrote:
> > > Hi,
> > > 
> > > In this code:
> > > 
> > > if set(a).union(b) == set(a): pass
> > > 
> > > Does Python compute set(a) twice?
> > 
> >     CPython does.  Shed Skin might optimize.  Don't know
> > about Iron Python.
> 
> I doubt any actual Python implementation optimizes this -- how could it? 

And why should it if a programmer uses its facilities inefficiently. I
would write

>>> if set(a).issuperset (b): pass

Frederic



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

Reply via email to