Why is there such a dramatic performance gap / slowdown for 3.10 + 3.11 compared to 3.9.12?
Re:Python 3.11 is faster than 3.8
by qbasic_forever on Wednesday October 26, 2022 @12:45PM
(#33346270)
That'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.
Oops, thanks for clarifying.
Re:Python 3.11 is faster than 3.8
by charlieyu1 on Wednesday October 26, 2022 @01:46PM
(#33346995)
Does pypy support numpy now?
yes
$ 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.]]
Re:Python 3.11 is faster than 3.8
by arc-in-space on Wednesday October 26, 2022 @12:45PM
(#33346269)
That's 3.9.12 of PyPy, not CPython
Not OP, but are you taking into consideration that it is not Python 3.9, but pypy, which is distinct
> 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.
It looks very close for 3.11. The measurement from the parent comment includes two other python implementations (not covered in the article).
Out 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_64makes sense I guess, it's had a lot more development time I'm sure. Thanks!
I think PyPy runs under Rosetta on M1, so the overhead is probably from that.
I don't think so; they released ARM support a while ago: 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/
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!
On my machine (very similar, a macbook pro m1 max):
(This test is basically a perfect test for JITs: one loop repeated many times)https://gist.github.com/llimllib/7af8144a92d3c2e1fc58be62988...