[pypy-dev] Performance challenge of mutating class variables

Armin Rigo arigo at tunes.org
Sat May 14 11:41:38 CEST 2011


Hi David,

On Fri, May 13, 2011 at 10:10 PM, David Edelsohn <dje.gcc at gmail.com> wrote:
> The problem was due to the user program's use of a class
> variable as a counter, which caused "unfortunate" behavior in the
> IronPython implementation -- mutating the variable invalidated the
> cache.

PyPy has indeed mostly the same behavior, but it is still faster than
CPython on the example you give.  It is because you don't do anything
with the Nodes.  If we modify the example
(http://paste.pocoo.org/show/388541/) to read all '_children'
attributes after all Nodes have been created, then PyPy is very slow.
In this example it is 4x slower than CPython when called with 2000000.

Thanks for pushing us in trying to find a solution for this problem :-)


A bientôt,

Armin.


More information about the pypy-dev mailing list