[pypy-dev] A simple file reading is 2x slow wrt CPython

Oscar Benjamin oscar.j.benjamin at gmail.com
Mon Jun 29 15:49:20 CEST 2015


On Mon, 29 Jun 2015 at 14:44 Oscar Benjamin <oscar.j.benjamin at gmail.com>
wrote:

With your code (although I didn't import io.open) I found the timings:
> CPython 2.7: 1.4s
> PyPy 2.7: 2.3s
>
> I changed it to
> for line in f: # (not f.readlines())
>     a += len(line)
>
> With that change I get:
> CPython 2.7: 1.3s
> PyPy 2.7: 0.6s
>
>
Note that all of the timings above are "warm cache". That means that the
file was already cached in memory by the operating system because I had
recently read/written it. The time taken to load the file cold cache (e.g.
after rebooting) would probably be much longer in all cases so that the
difference between PyPy and CPython would not be significant. The problem
you've posted should really be IO bound which isn't really the kind of
situation where PyPy gains you much speed over CPython.

--
Oscar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20150629/c2a32b38/attachment.html>


More information about the pypy-dev mailing list