Skip to content
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

Add pypy support #74

Merged
merged 3 commits into from
May 29, 2020
Merged

Add pypy support #74

merged 3 commits into from
May 29, 2020

Conversation

pganssle
Copy link
Owner

For now this only works with source distributions — I'd like to ship a PyPy wheel, but I can't figure out how to tag it so that it will only get picked up on PyPy.

I have an alternate version of this that actually allows the C extension to compile on PyPy, but on PyPy the C extension is way slower than the Python implementation (which for a lot of these benchmarks is actually faster than the C extension on CPython):

Running constructor in zone America/New_York
c_zoneinfo: mean: 490.79 ns ± 16.89 ns; min: 468.35 ns (k=5, N=1000000)
py_zoneinfo: mean: 49.54 ns ± 2.07 ns; min: 47.39 ns (k=5, N=10000000)
pytz: mean: 1.71 µs ± 70.73 ns; min: 1.66 µs (k=5, N=1000000)

Running constructor_strong_cache_miss in zone America/New_York
c_zoneinfo: mean: 28.57 µs ± 3.71 µs; min: 24.29 µs (k=5, N=10000)
py_zoneinfo: mean: 957.39 ns ± 40.07 ns; min: 913.89 ns (k=5, N=1000000)

Running from_utc in zone America/New_York
c_zoneinfo: mean: 4.93 µs ± 143.32 ns; min: 4.73 µs (k=5, N=100000)
py_zoneinfo: mean: 495.16 ns ± 41.14 ns; min: 452.01 ns (k=5, N=1000000)
pytz: mean: 627.67 ns ± 12.06 ns; min: 614.56 ns (k=5, N=1000000)

Running no_cache_constructor in zone America/New_York
c_zoneinfo: mean: 264.79 µs ± 36.98 µs; min: 229.38 µs (k=5, N=1000)
py_zoneinfo: mean: 106.52 µs ± 63.78 µs; min: 51.60 µs (k=5, N=1000)

Running to_utc in zone America/New_York
c_zoneinfo: mean: 3.44 µs ± 60.76 ns; min: 3.37 µs (k=5, N=100000)
py_zoneinfo: mean: 472.54 ns ± 39.36 ns; min: 432.28 ns (k=5, N=1000000)
pytz: mean: 332.76 ns ± 3.78 ns; min: 328.54 ns (k=5, N=1000000)

Running utcoffset in zone America/New_York
c_zoneinfo: mean: 3.45 µs ± 52.71 ns; min: 3.40 µs (k=5, N=100000)
py_zoneinfo: mean: 336.64 ns ± 11.60 ns; min: 325.69 ns (k=5, N=1000000)
pytz: mean: 213.31 ns ± 5.82 ns; min: 204.82 ns (k=5, N=10000000)

In the future, we'll probably want to be smarter about dropping the C extension tests entirely on PyPy, since this basically just runs all the same tests twice right now.

This skips building the C extension and only uses the pure Python
version when built on PyPy. This is probably the right thing to do on
PyPy anyway, since PyPy needs to use a compatibility layer for the C
extension, and that slows things down considerably.

Running the benchmark suite, the C extension is consistently 10x slower
than the pure Python implementation on PyPy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant