



TLDR; I'm at the

https://youtu.be/WN1slc5O8os Hi,TLDR; I'm at the pypy sprint, and working through the remaining pygame-on-pypy-cpyext issues.



Surprisingly to me... it's already usable. That is pygame (same one that runs on cpython), works on pypy through its C extension API. pypy has good support for the CPython API (through a recompile) now. PyPy is the python language with a fast JIT, so your code can approach C speeds. And in some cases it can be faster than C.



There was an issue with events stopping keyboard/mouse/etc from working. Lots of details in this issue describing the changes needed, so I hope other extensions encountering this will find it useful. https://github.com/pygame/ pygame/issues/419



Cat sitting in the fog and snow of Switzerland Why is this exciting? This is exciting to me because: But now that's fixed, every pygame app I tried on it has worked.This is exciting to me because:

pure python code being fast on pypy(after warmup), also mixed with the fast bits in C/asm.

cpyext is getting faster in pypy. There is already work and discussion towards it being faster than CPython.

maintaining one pygame code base is easier than maintaining several (pygame cffi/ctypes/cython, ...).

with one code base it should be fast on both pygame, and pypy(in time).



https://youtu.be/WN1slc5O8os Here's our old pal solarwolf from early 2000s running on pypy.

Still lots of work to do (especially around PixelArray buffers and such). Then of course, there is the issue of binary wheels, so that ` pip install pygame ` works without needing to compile things from source.





How is the speed? (when do we use this tool? Is it fast enough?) If your code is already quite well optimized, and not spending much time in python, you can't expect to see an improvement. However, if you are pushing boundaries in your python code, you can expect very good increases.







if profiling and a pygame function (like blit) isn't at the top of the slow bits.

collision detection (if you aren't using fancy algorithms).

a pure python ray caster.

writing a music synthesizer in python python. Some examples where you can expect it to be faster:



if you are going into C code for a lot of small operations. Like when using lots of pygame.Rect in a tight loop. This is because (currently) the cost of going from PyPy code into and out of CPython API code (like pygame) is a bit slow. Where it can be slower.

Ray tracing 3D scenes.

Ray Tracer to for realistic 3D lighting.

The fog has lifted at the Leysin pypy sprint.

For me, I'm interested mostly in this for a physics art project which was really slow, and also for a software music synth written in pure python. Even more interesting is running pypy as a separate process for these tasks, and run the gui process with CPython.Here I run a python and pygame python ray tracer by Ian Mallett.On PyPy - 18.6 seconds.On Python 2.7 - 9 minutes, 28.1 secondsThat's. Making many more things possible in python - and at speed.