Not Always PyPy Is Faster

PyPy is an alternative Python interpreter, which is known for it’s speed.  However it does not have to be always faster as ‘classic’ Python interpreter (called here CPython). For one small project of mine – PDF Checker – I was testing PyPy hoping to speed up PDF document processing (basically parsing to extract text – pdfminer library is used and document parsing takes majority of time).  Below are results from running program for two different files and in CPython interpreter or in PyPy (with JIT and without JIT compilation):

CPython PyPy PyPy with JIT disabled
Small PDF (110kB)  1.1 s  2.4 s  2.5 s
Big PDF (996kB)  16.6 s  10.9 s  36.5 s

Clearly for smaller file CPython is notably faster – about 2x. I assume that overhead of JIT is not payed off by achieved speed up.  This starts to show off only for larger files.

Tested with CPython 2.7.6 , PyPy 2.3.1   on Linux (Ubuntu 14.04  64 bit) with Intel Core i5 CPU @ 2.7 GHz and 8GB memory.

Leave a Reply

Your email address will not be published. Required fields are marked *