[pypy-dev] Performance challenge of mutating class variables

Carl Friedrich Bolz cfbolz at gmx.de
Sat May 14 20:15:57 CEST 2011


On 05/14/2011 11:41 AM, Armin Rigo wrote:
> 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 :-)

Did you try this with PyPy 1.5 or a recent nightly? I thought that the 
new type __dict__ implementation should have fixed the problem?

Carl Friedrich


More information about the pypy-dev mailing list