candl 10 days ago

I recently had to script reading a large Excel XLSB file. Using pyxlsb it took about two minutes. I found an alternative library with significally better performance - python-calamine, but this one reads all the data to memory consuming GBs of RAM, so was a no starter. Then I tried PyPy and miraculously the same script with pyxlsb takes 15 seconds.

giancarlostoro 10 days ago

I never really did much with PyPy, do people mostly use it in a deployed application setting? I ask because looking over at the PyPy Speed page...

https://speed.pypy.org/

Looks like Django is insanely faster under PyPy. Feels like a potential waste not to use PyPy on a deployed web app in most cases. I wonder how FastAPI scales with PyPy and other Python interpreters.

  • JulianWasTaken 10 days ago

    At least for me / my former $WORK, the answer was "definitely yes we used it in deployed applications", we saved more than $1M (this in ~2015) annually in infrastructure costs by quite literally switching from CPython to PyPy and never really looked back, but obviously there are many considerations involved there that are going to be specific to your (company's) application(s) and infrastructure.

  • jmg_ 10 days ago

    Note they're comparing to CPython v3.7 and while https://speed.python.org doesn't go back to 3.7, the improvements between 3.8 to 3.12 are pretty massive.

    I don't doubt PyPy is faster than CPython, but it would be very interesting to see latest PyPy compared to latest CPython.

  • doix 10 days ago

    I used it at my old job specifically to speed up a Django application.

    After a bunch of profiling, I narrowed down a bunch of our performance problems to the ORM doing a bunch of __setattr__ (or something, it was a long time ago).

    We could have started rewriting everything and using .values() (or something, basically get back tuples instead of python objects) but switching to PyPy got the performance to good enough without having to sacrifice DX.

    It's been a long time, so I'm a bit fuzzy on the details, but I definitely recommend PyPy for Django unless there's some reason you can't use it.

  • ktm5j 10 days ago

    I've put a bit of effort into trying to make it work with the python apps we write at my company. We have a lot of electrical engineers who only write python and we're butting up against the limit of what the language can do as far as the data we need to process..

    It's worked well in some cases, but the main situation where we needed it to work was with a GUI application where there was no separation between computation and the GUI elements.. I tried really hard, and got frustratingly close, but could not build wxPython that would work using pypy.

    But it's super cool imo, as someone who has to write/maintain python code it's awesome to see some innovative work to make the language faster.

    • stuaxo 9 days ago

      Gtk could be an option it used to not work well at all, but since they improved their C binding support it got better.

      • ktm5j 9 days ago

        Good to know, thanks!

    • giancarlostoro 9 days ago

      I havent used it in a long time but did you try Qt as well? PySide worked insanely nicely for me. Although this wasnt with PyPy to be fair.

      • ktm5j 9 days ago

        Well the thing is that it's code that's already been written, and honestly is kind of a mess. It would take more effort than it's worth to try and rewrite using a different GUI framework.

        I much prefer Qt but this was written before I started here so it is what it is :/

        The longer the test runs we end up losing data because they're looping over a dataframe that keeps growing and growing and the program just can't finish that loop in the 2 seconds that it has to run. But it's not a big enough deal for us to fix

  • eugenekolo 10 days ago

    I run it in a production environment (side project). I also use it locally when developing when necessary.

    It really does speed up loops by 5x or so.

    So when you're trying to say... test 100 million+ iterations of something, pypy will run that in something like 2 minutes versus cpython can take me 15 minutes.

    Honestly it's an amazing performance gain for 0 effort, and I have yet to run into a limitation with it.

  • lend000 10 days ago

    I used it in production for a while, but it caused instability with pandas and often froze so I had to take it out. It does have some serious speed benefits for simple / pure-Python without compiled libraries.

  • stuaxo 9 days ago

    I think you have to start your Django project with PyPy, it's always a gamble which dependencies will work with it, and for a project already going the chances are that something won't work.

    If you find something like that it's worth reporting, there are less of them over time.

    • giancarlostoro 9 days ago

      Awesome I will keep this in mind since I am working on a new Django project, thanks!

  • mdaniel 10 days ago

    In my specific circumstance it behaved like a statically linked, one-.tar-and-ready mechanism to get python onto Flatcar (nee CoreOS, but not the modern one). So my case for it wasn't speed it was the dead simple deploy

sneed_chucker 10 days ago

Still crazy to me that Python is this popular in all sorts of production uses without a JIT reference implementation.

  • notatallshaw 10 days ago

    A JIT is now available in CPython main, it's not that performant yet so won't be turned on for Python 3.13 by default, informational PEP is here (still being reviewed, check the discourse thread for more details): https://peps.python.org/pep-0744/

  • pjmlp 9 days ago

    Definitly, one hardned lesson from my Tcl days, on the startup that used a AOLServer like product, was to never again use dynamic languages without any sort of JIT/AOT toolchains for production delivery of products, only scripting stuff.

    Apparently it took Microsoft and Facebook to actually change the minds of CPython core team, however what is coming on 3.13 is only the start.

albertzeyer 10 days ago

Is there an overview of the user share of PyPy vs CPython? I have the feeling that PyPy usage became less in the recent years.

How well does PyPy work together with frameworks like PyTorch, JAX, TensorFlow, etc? I know there has been some work to support NumPy, but I guess all these other frameworks are much more relevant nowadays.

abeppu 10 days ago

Does PyPy still release 2.7 because RPython is still based on it?

I was recently trying to play with RPython for the first time, and having to remember all the python 2 vs python 3 differences felt strange, and very retro.

  • JulianWasTaken 10 days ago

    Developing / helping contribute to PyPy may mean touching 2.7 in its toolchain which is used to implement it, but no, users using it have been able to use 3.x for a very very long time now.

    • abeppu 10 days ago

      You'll note I said I was playing with RPython, not PyPy. In my case, I was playing with writing a small interpreter, and comparing the RPython toolchain with the Truffle/Graal framework.

      Writing RPython code, even if one is not developing or contributing to PyPy, means writing within a subset of python 2.

      > RPython ("Restricted Python") is a subset of Python 2

      https://www.pypy.org/posts/2022/04/how-is-pypy-tested.html

      And RPython's translator specifically uses pypy, and uses python 2 syntax:

      https://github.com/pypy/pypy/blob/main/rpython/bin/rpython#L...

      ... so getting the RPython toolchain (even if one is intending to improve the PyPy 3+ interpreters) requires setting up a pypy 2 interpreter. Hence the question in my post.

singularity2001 10 days ago

Too bad they don't compile to wasm. Shouldn't be tooo hard.

brian_herman 10 days ago

Why do they have 3.9 and 3.10 is it their policy to have two previous versions for every release?

  • mattip 9 days ago

    We try to keep around useful versions of Python3, based on what wheels packagers make available. NumPy<2 provides PyPy3.9 wheels, and we have PyPy3.10 ready. Now that NumPy has moved to PyPy3.10 wheels, we will probably drop 3.9. Help is needed to move forward to 3.11/3.12.