New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile gevent.local.py with Cython when available. #1024

Merged
merged 3 commits into from Sep 25, 2017

Conversation

Projects
None yet
1 participant
@jamadden
Member

jamadden commented Sep 25, 2017

This makes things much faster, even over #1020 (the inclusion of the .pxd file and direct access for _localimpl made the biggest difference). We had to make some small code changes to acheive this (things like directly accessing variables instead of redirecting through object.__getattribute__), but this didn't impact PyPy at all (in fact it may actually be faster).

New timings compared to previous commit (#1020):

Operation PyPy 2 Python 2.7 Python 3.6
getattr local 76ns 233ns 206ns
setattr local 79ns 232ns 202ns
getattr subclass 77ns 238ns 203ns
setattr subclass 75ns 238ns 204ns
getattr native local 2ns 139ns 73ns
setattr native local 2ns 168ns 98ns
getattr slowdown 38x 1.7x 2.8x
setattr slowdown 39x 1.7x 2.1x
Compile local.py with Cython when available.
This makes things *much* faster. We had to make some small code
changes to acheive this (things like directly accessing variables
instead of redirecting through object.__getattribute__), but this
didn't impart PyPy at all (in fact it may actually be faster). New
timings compared to previous commit:

| Operation             | PyPy 2        | Python 2.7    | Python 3.6    |
|---------------------- |-------:       |-----------:   |-----------:   |
| getattr local         |   76ns        |      233ns    |      206ns    |
| setattr local         |   79ns        |      232ns    |      202ns    |
| getattr subclass      |   77ns        |      238ns    |      203ns    |
| setattr subclass      |   75ns        |      238ns    |      204ns    |
| getattr native local  |    2ns        |      139ns    |       73ns    |
| setattr native local  |    2ns        |      168ns    |       98ns    |
| getattr slowdown        	|  38x 	|     1.7x 	|     2.8x 	|
| setattr slowdown        	|  39x 	|     1.7x 	|     2.1x 	|

@jamadden jamadden force-pushed the cython-local branch from a542af9 to 5ba9ab7 Sep 25, 2017

jamadden added some commits Sep 25, 2017

Support using the pure python local code on Cpython too; it handles a…
…dding __new__ differently than PyPy does.

@jamadden jamadden merged commit 4580712 into master Sep 25, 2017

2 of 5 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
coverage/coveralls Coverage pending from Coveralls.io
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@jamadden jamadden deleted the cython-local branch Sep 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment