New issue 2728: performance collapse with setattr in a large for-loop
https://bitbucket.org/pypy/pypy/issues/2728/performance-collapse-with-setattr-in-a

biblicabeebli:

Hi...

I was interested in testing the performance difference between CPython's 
attribute assignment on class objects and dictionary key value assignment.  I 
wrote a (bad) script to test this, ensured it was compatible and equivalent 
between Python 2 and 3, and ran it on CPython 2.7 and 3.6.  Then, for goofs, I 
thought I would test it on pypy.

pypy version info:
pypy3.5-5.10
compiled using pyenv 1.2.0-8-g785738d
running on mac os 10.11.6
clang version:
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Well, it either never finishes execution, or it takes more than 1 minute vs 
CPython's 0.057096 execution of that problematic for-loop on my computer.

The eventual stack trace when after I hit ^C is pasted below, I therefore 
assume it is setattr that is causing the issue.  Note: I tested both the 
class's __setattr__ method and the built in setattr() function, both have this 
problem.

^C
Traceback (most recent call last):
  File "dict_class_test.py", line 104, in <module>
    do(100000)  # <-- takes forever???
  File "dict_class_test.py", line 41, in do
    x.__setattr__(i_string, i)


_______________________________________________
pypy-issue mailing list
pypy-issue@python.org
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to