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

Carl Friedrich Bolz cfbolz at gmx.de
Mon Jun 29 16:33:15 CEST 2015


Hi Ozan,

in addition to what the others said of not using readlines in the first
place: I actually discovered a relatively slow part in our
file.readlines implementation and fixed it. The nightly build of tonight
should improve the situation.

Thanks for reporting this! Out of curiosity, what are you using PyPy for?

Cheers,

Carl Friedrich

On 29/06/15 15:02, Ozan Çağlayan wrote:
> Hi,
>
> I just downloaded PyPy 2.6.0 just to play with it.
>
>
> I have a simple line-by-line file reading example where the file is 324MB.
>
> Code:
>
> # Not doing this import crashes PyPy with MemoryError??
> from io import open
>
> a = 0
> f = open(fname)
> for line in f.readlines():
>    a += len(line)
> f.close()
>
> PyPy:
> Python 2.7.9 (295ee98b69288471b0fcf2e0ede82ce5209eb90b, Jun 01 2015, 17:30:13)
> [PyPy 2.6.0 with GCC 4.9.2] on linux2
>
> real 0m6.068s
> user 0m4.582s
> sys 0m0.846s
>
> CPython (2.7.10)
>
> real 0m3.799s
> user 0m2.851s
> sys 0m0.860s
>
> Am I doing something wrong or is this expected?
>
> Thanks!
>



More information about the pypy-dev mailing list