Live data from Hacker News

Ask HN: Is anyone using PyPy for real work?

news.ycombinator.com

61–70 of 185 posts

Re: Ask HN: Is anyone using PyPy for real work?

#61
post #55
post #25

I use it at work for a script that parses and analyzes some log files in an unusual format. Wrote a naive parser with a parsing combinator library. It was too slow to be usable with CPython. Tried PyPy and got a 50x speed increase (yes, 50 times faster). Very happy with the results, actually =)

Thanks for the feedback. It does seem like parsing logs and simulations is a sweet spot for PyPy

Simulations are, at least in my experience, numba’s [0] wheelhouse.

[0]: https://numba.pydata.org/

Re: Ask HN: Is anyone using PyPy for real work?

#62
I've used it at work to speed up some standard Python code (without any c-bound library usage). It sped up the code by 5 times.

I've deployed used the pypy:3.9 image on docker.

One thing I did notice is that it was significantly faster on my local machine vs when I tried to deploy it using an AWS lambda/fargate. I know this is because of virtualization/virtual-cpu, but there was not much I could do to improve it.

Re: Ask HN: Is anyone using PyPy for real work?

#63
I'm building a bot detector api to use with our CDN and using pypy was decided on day one, without pypy the performance is just not there.

Also in my day job we use pypy in all our python deployments, to be fair until now I thought that everybody would develop in python, test in pypy for an easy speed boost and only got back to python if pypy was slower than cpython

Re: Ask HN: Is anyone using PyPy for real work?

#64
post #49
post #35

Earlier quoted context omitted.

dist packages are a must for software written in Python that is part of the distribution itself.

You're not really answering why they are important? Is it because .deb packages will install inside dist-packages and when you run pip install as root without a virtual env, it installs inside site-packages? I don't really see how this helps though? Sure you won't get paths to clash between the two but you still have duplicate packages which is probably not what you want..

Debian ships packages with a coherent dependency structure that crosses language boundaries. You don't need to care what language something is written in to be able to "apt install" it. The expectation is that if it "apt installed" then it should Just Work because all the required dependencies were also pulled in from Debian at the same time.

Debian also tries to ship just one version of everything in a single distribution release to reduce the burden on its maintainers.

This is fundamentally at odds with pip. If you've pip installed something, then that'll likely be the latest version of that package, and in the general case won't be the version of the same thing that shipped in the Debian release. If there exist debs that depend on that package and they are shared between pip and debs, now the deb could be using a different version of the dependency than the deb metadata says is acceptable, leading to breakage.

Another way of putting this: it shouldn't be possible for you to pip upgrade a dependency that a deb shipped by Debian itself relies upon. Because then you'd creating a Frankenstein system where Debian cannot rely on its own dependencies providing what it expects.

This is fixed by having two places where things are installed. One for what the system package manager ships, and one for your own use with pip and whatever you want to do. In this sense, having duplicate packages is actually exactly what you want.

Re: Ask HN: Is anyone using PyPy for real work?

#65
post #49
post #35

Earlier quoted context omitted.

dist packages are a must for software written in Python that is part of the distribution itself.

You're not really answering why they are important? Is it because .deb packages will install inside dist-packages and when you run pip install as root without a virtual env, it installs inside site-packages? I don't really see how this helps though? Sure you won't get paths to clash between the two but you still have duplicate packages which is probably not what you want..

Imagine you installed python3-requests (version x.y.z). Some of your distribution's packages depend on that specific package/version.

If you pip install requests globally, you just broke a few of your distrib's packages.

Re: Ask HN: Is anyone using PyPy for real work?

#66
post #42
post #30

I put PyPy in production at a previous job, running a pretty high traffic Flask web app. It was quick and pretty straightforward to integrate, and sped up our request timings significantly. Wound up saving us money because server load went down to process the same volume of requests, so we were able to spin down some instances. Haven’t used it in a bit mostly because I’ve been working on projects that haven’t had the…

You're welcome. > that rely on incompatible extensions. Which ones? Is using conda an option, we have more luck getting binary packages into their build pipelines than getting projects to build wheels for PyPI

I can't actually remember off of the top of my head, I tried it out a year or two ago but didn't get too far because during profiling it became clear the biggest opportunities for performance improvement in this app were primarily algorithmic/query/io optimizations outside of Python itself, so business-wise it didn't make too much sense, though if it had I think using Conda would have been on the table. We make heavy use of Pandas/Numpy et al, though I know those are largely supported now so I'd guess it was not one of them but something adjacent.

Re: Ask HN: Is anyone using PyPy for real work?

#67
Can someone ELI5 why pypy doesn't or can't work with C-based packages like numpy or psycopg? I know nothing of how pypy does its magic.

If we could use pypy, while still using those packages, I think it'd be the go-to interpreter. Why can't pypy optimize everything else, and leave the C stuff as-is?

How does pypy handle packages written in other languages, like rust? can I use pypy if I depend on Pydantic?

Re: Ask HN: Is anyone using PyPy for real work?

#68

I've never used it because the (unknown) effort of switching and the chance of compatibility issues have always made it unappealing compared to just switching to a faster language. If I could just `pip3 install pypy` and then set an environment variable to use it or something like that then I'd give it a try. It does feel a bit like adding a jet pack to a rowing boat though. I know some people use Python in situation…

If you use a version manager like rtx or asdf then it’s basically that simple. I just had to run a single command:

    rtx use python@pypy3.10
This downloaded and installed PyPy v3.10 in a few seconds and created an .rtx.toml file in the current directory that ensures when I run python in that directory I get that version of PyPy.

Re: Ask HN: Is anyone using PyPy for real work?

#69
post #25

I use it at work for a script that parses and analyzes some log files in an unusual format. Wrote a naive parser with a parsing combinator library. It was too slow to be usable with CPython. Tried PyPy and got a 50x speed increase (yes, 50 times faster). Very happy with the results, actually =)

what cpython version and OS was that? I'd be very surprised if modern Python 3.11 has anything an order of magnitude slower like that. things have gotten much faster over the years in cpython

Re: Ask HN: Is anyone using PyPy for real work?

#70
post #9

This post is a funny coincidence as I tried today to speed-up a CI pipeline running ~10k tests with pytest by switching to pypy. I am still working on it but the main issue is psycopg support for now, as I had to install psycopg2cffi in my test environment, but it will probably prevent me from using pypy for running our test suite, because psycopg2cffi does not have the same features and versions as psycopg2. This me…

I work on pg8000 https://pypi.org/project/pg8000/ which is a pure-Python PostgreSQL driver that works well with pypy. Not sure if it would meet all your requirements, but just thought I'd mention it.
Post reply on HN