[pypy-dev] PyPy 2x slower using cpickle

Eleytherios Stamatogiannakis estama at gmail.com
Thu Jul 18 13:25:28 CEST 2013


Yes you are right, cPickle.dump most probably does a lot more small writes.

On the other hand, shouldn't this also affect CPython? Or is CPython so 
much faster in "".join-ing strings?

Is "".join-ing something that we should generally avoid doing in PyPy?

l.

On 18/07/13 13:53, Amaury Forgeot d'Arc wrote:
> 2013/7/18 Eleytherios Stamatogiannakis <estama at gmail.com
> <mailto:estama at gmail.com>>
>
>     Why is there such a huge speed difference between cPickle.dump( ...
>     f) and f.write(cPickle.dumps(...)) ?
>
>
> Did you count the number of calls to f.write?
> pickle call write() once per pickled object.
>
> Now, pypy's implementation of buffered file uses a (RPython) list of
> strings, and does a final ''.join.
> This is probably much less efficient than the RStringIO implementation.
>
> --
> Amaury Forgeot d'Arc



More information about the pypy-dev mailing list