You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python 2.7 wheel for C-extension is slower than the egg/local-version on Windows #1154
I have a Python 2.7 C-extension that was made for performance, however, I noticed something strange on Windows:
When I run locally python setup.py install and it installs it the "egg" way, the performance of running the module 500x in a loop is:
yEnc C New took 579 ms
yEnc C New took 580 ms
yEnc C New took 580 ms
But when I install it as a wheel locally or via pip without a single change to the C-code, this is the result:
yEnc C New took 702 ms
yEnc C New took 694 ms
yEnc C New took 691 ms
That's a 15-20% difference..
I also checked macOS and Ubuntu, here it does not seem to be the case.
To reproduce run and look at the yEnc C New score between the 2 ways:
Upon further inspection, when using (after removing existing dist and build folders):
python setup.py install_lib
It also creates the slower version.
I compared compiler commands as printed during the building, and they were they same.
Beware that you have to manually remove the sabyenc.pyd file from the site-packages directory after this last command for continued testing!
I updated the wheel and setuptools to their latest versions before all this testing.
Oke so the difference is in the bootstrap-loader that comes included in the egg.
When I only unpacked the sabyenc.pyd from the .egg into the site-packages directory, it was again slow.
However, when I then renamed the file to sabyenc_.pyd, then unpacked from the .egg also the bootstrap loader sabyenc.py and changed it to:
But as this is about Python 2.7 interest is understandably very low, so I'll close this now.
Let's see if the same thing also happens when I port the module to Python 3.
Activity
Safihre commentedon Sep 19, 2017
Upon further inspection, when using (after removing existing
distandbuildfolders):It also creates the slower version.
I compared compiler commands as printed during the building, and they were they same.
Beware that you have to manually remove the
sabyenc.pydfile from thesite-packagesdirectory after this last command for continued testing!I updated the
wheelandsetuptoolsto their latest versions before all this testing.Safihre commentedon Sep 19, 2017
Oke so the difference is in the bootstrap-loader that comes included in the egg.
When I only unpacked the
sabyenc.pydfrom the.egginto thesite-packagesdirectory, it was again slow.However, when I then renamed the file to
sabyenc_.pyd, then unpacked from the.eggalso the bootstrap loadersabyenc.pyand changed it to:It is fast again...
What is happening here?!
EDIT: Continued testing revealed that
py2exeloads the files in the "fast" way, so at least our users get the fast experience anyway 🏅Safihre commentedon Sep 21, 2017
Could this be a python bug in the way libraries are loaded? And should I report it to the Python bugtracker?
Safihre commentedon Oct 1, 2017
Python developers are sure it's a problem of setuptools and wheel: https://bugs.python.org/issue31555
But as this is about Python 2.7 interest is understandably very low, so I'll close this now.
Let's see if the same thing also happens when I port the module to Python 3.