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

Ozan Çağlayan ozancag at gmail.com
Mon Jun 29 15:02:23 CEST 2015


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!

-- 
Ozan Çağlayan
Research Assistant
Galatasaray University - Computer Engineering Dept.
http://www.ozancaglayan.com


More information about the pypy-dev mailing list