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 <[email protected]
<mailto:[email protected]>>

    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

_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to