[pypy-issue] [issue865] Struct.pack and unpack 3x and 6x slower than CPython

Josh Ayers tracker at bugs.pypy.org
Thu Sep 8 05:23:06 CEST 2011

New submission from Josh Ayers <josh.ayers at gmail.com>:

Using struct.pack and struct.unpack is significantly slower on PyPy 1.6 than on
CPython 2.7.2 when packing a large list.  This is under Windows 7.

A summary of the timing results is shown below and the code used is attached. 
The attached code uses 4 byte integers.  Floats show similar results.

              4 MB              40 MB          80 MB
           pack  unpack      pack  unpack   pack  unpack
 CPython   0.13  0.03        1.30  0.29     2.60  0.60
 PyPy      0.43  0.20        3.90  1.77     8.03  3.59
 Factor    3.3x  6.7x        3.0x  6.1x     3.1x  6.0x

The benchmark code packs a large list, writes it to a file, then reads the file
back in and unpacks it.  I didn't include it in the table above, but the reading
portion was also slower in PyPy.  However, it wasn't as large of a difference as
the struct packing and unpacking portion.

messages: 3105
nosy: jayers2003, pypy-issue
priority: feature
status: unread
title: Struct.pack and unpack 3x and 6x slower than CPython

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list