Il giorno 03/lug/2013 18:17, "Amaury Forgeot d'Arc" <amauryfa@gmail.com> ha scritto:

> This is because of I/O.
> If I replace the file with a custom class which has an empty write() method,
> pypy is twice faster than CPython.

Few days ago I discovered that there is an easy optimization for this. If you look at how str2charp & friends are implemented, you see that we do an RPython loop and copy char by char.
By contrast, things like string concatenation are implemented using memcpy and are much faster (like 3-4 times, iirc).
Sorry if I don't give more precise pointer, but I'm on my mobile phone :-)