4 ms·
I wanted to see what the results for pypy would be. On my machine (very similar, a macbook pro m1 max): python 3.10: 52s python 3.11: 35s pypy 3.9
by llimllib 4y ago
I wanted to see what the results for pypy would be.
On my machine (very similar, a macbook pro m1 max):
python 3.10: 52s
python 3.11: 35s
pypy 3.9.12: 10s
(This test is basically a perfect test for JITs: one loop repeated many times)
https://gist.github.com/llimllib/7af8144a92d3c2e1fc58be62988074e0 https://gist.github.com/llimllib/7af8144a92d3c2e1fc58be62988...
- deleted 4y ago[deleted]
- metadat 4y agoWhy is there such a dramatic performance gap / slowdown for 3.10 + 3.11 compared to 3.9.12?
- arc-in-space 4y agoThat's 3.9.12 of PyPy, not CPython
- qbasic_forever 4y agoThat's pypy 3.9.12, it has a JIT implementation to interpret python. The other two are standard CPython which doesn't JIT interpret the code.
- metadat 4y agoOops, thanks for clarifying.
- charlieyu1 4y agoDoes pypy support numpy now?
- llimllib 4y agoyes $ pip install numpy <snip building wheel> $ python --version && python -c "import numpy; print(numpy.identity(5))" Python 3.9.12 (05fbe3aa5b0845e6c37239768aa455451aa5faba, Mar 29 2022, 09:54:47) [PyPy 7.3.9 with GCC Apple LLVM 13.0.0 (clang-1300.0.29.30)] [[1. 0. 0. 0. 0.] [0. 1. 0. 0. 0.] [0. 0. 1. 0. 0.] [0. 0. 0. 1. 0.] [0. 0. 0. 0. 1.]]
- fordsmith 4y agoNot OP, but are you taking into consideration that it is not Python 3.9, but pypy, which is distinct
- deleted 4y ago[deleted]
- masklinn 4y ago> On my machine (very similar, a macbook pro m1 max): Should make essentially no difference then, since I rather doubt the Python implementation of n-body can leverage the GPU, or strains the RAM so much that the 200GB/s of the Pro (IIRC) would be an issue.
- bee_rider 4y agoIt looks very close for 3.11. The measurement from the parent comment includes two other python implementations (not covered in the article).
- CalebJohn 4y agoOut of curiosity I ran the same test on a linux laptop with the Ryzen 7 PRO 6850U CPU. python 3.10: 60s python 3.11: 46s pypy 3.9.12: 6s Looks like pypy performs comparatively better on x86_64
- nerdponx 4y agoI think PyPy runs under Rosetta on M1, so the overhead is probably from that.
- llimllib 4y agoI don't think so; they released ARM support a while ago: https://doc.pypy.org/en/latest/release-2.1.0.html https://doc.pypy.org/en/latest/release-2.1.0.html (I could be wrong) edit: oh, huh I think you're right that it's running here on rosetta: $ file installs/python/pypy3.9-7.3.9/bin/pypy installs/python/pypy3.9-7.3.9/bin/pypy: Mach-O 64-bit executable x86_64 Wonder if there's a way to run a native version? edit 2: there are nightlies here: https://buildbot.pypy.org/nightly/py3.9/ https://buildbot.pypy.org/nightly/py3.9/ Running the latest, a native binary gives more than 2x speedup: # first you have to allow all the unsigned binaries to run $ xattr -dr com.apple.quarantine pypy-c-jit-106295-5dd3b18303e2-macos_arm64/bin/* # then we get 3.5s: $ time pypy-c-jit-106295-5dd3b18303e2-macos_arm64/bin/pypy nbody.py 10000000 -0.169075164 -0.169077842 real 0m3.522s user 0m3.468s sys 0m0.045s pypy continues to impress!
- llimllib 4y agomakes sense I guess, it's had a lot more development time I'm sure. Thanks!
- deleted 4y ago[deleted]