Thomas Jollans wrote:
What if "set" has side effects? A
compiler could only exclude this possibility if it knew exactly what "set"
will be at run time,
And also that 'a' remains bound to the same object, and that
object or anything reachable from it is not mutated in
any way that could affect
John Nagle wrote:
> I was talking to the Facebook guys doing the compiler for PHP, and they
> said that it was a huge win for them that PHP doesn't allow dynamically
> replacing a function.
I'm not sure if I call all that effort for a 50% speed increase a win.
PyPy is seeing speed increases of up
On 8/18/2010 3:12 PM, 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 kn
On 19 Ago, 08:40, Frederic Rentsch wrote:
> 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
>
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?
On Thu, Aug 19, 2010 at 9:12 AM, Thomas Jollans wrote:
> I doubt any actual Python implementation optimizes this -- how could it?
> The
> object "set" is clearly being called twice, and it happens to be called
> with
> the object "a" as a sole argument twice. What if "set" has side effects? A
> c
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
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.
John Nagle
--
http://mail.python.org/mailman/listinf
ernest wrote:
> In this code:
>
> if set(a).union(b) == set(a): pass
>
> Does Python compute set(a) twice?
>>> a = "abc"
>>> b = "def"
>>> _set = set
>>> def set(x):
... print "computing set(%r)" % x
... return _set(x)
...
>>> if set(a).union(b) == set(a): pass
...
computing set('abc')