Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unfortunately it's not a silver bullet for performance.

I have a relatively short Python program that does statistical analysis. It also contains a lot of string matching and is deeply recursive. I just added a benchmark mode, which gives the following (consistent) result:

Python 2.7.3: set solved in 16 seconds PyPy 2.0b2: set solved in 33 seconds (any initial IO is not part of the time, so the problem is entirely compute-bound and it pegs the CPU at 100%)

If there's something obvious I'm overlooking that would make PyPy faster I'd love to hear about it.



While I'm not a pypy developer, I know they treat any python* code running slower than cpython as a bug. They love to try and help with it if you stop by #pypy on freenode irc.

It's best if you can give them a self contained example they can download and run themselves to track down what is going on. If not (because it is closed source or such) they may or may not be able to do much, but are still more than happy to try and give some advice at least.

Janzert

* pure python, certain methods of interfacing with extension modules will probably always be rather slow and the solution is generally to either get rid of it or rewrite the interface to it using cffi.


Consider factoring your code into a benchmark and submitting it to the PyPy team. They have an awesome attitude toward this. From http://pypy.org/performance.html:

We generally consider things that are slower on PyPy than CPython to be bugs of PyPy. If you find some issue that is not documented here, please report it to our [bug tracker](https://bugs.pypy.org/) for investigation.

(bug tracker has broken SSL cert)


The PyPy memory usage also keeps increasing linearly during the benchmark, reaching 220MB at the end. The CPython version is using exactly 23MB for the entire run with zero fluctuation. I'm guessing the recursive nature of the program is killing PyPy.


Are you by chance using s += x to create strings? If so, stop. Anyway, my crystal ball is in service right now, you should really give us a chance to look at it.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: