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

Ryan Gonzalez rymg19 at gmail.com
Mon Jun 29 15:57:08 CEST 2015


Could you try just using:

for line in f:
    ...

That refrains from the loading the entire file into memory at once.


On June 29, 2015 8:02:23 AM CDT, "Ozan Çağlayan" <ozancag at gmail.com> 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!
>
>-- 
>Ozan Çağlayan
>Research Assistant
>Galatasaray University - Computer Engineering Dept.
>http://www.ozancaglayan.com
>_______________________________________________
>pypy-dev mailing list
>pypy-dev at python.org
>https://mail.python.org/mailman/listinfo/pypy-dev

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20150629/ff721615/attachment-0001.html>


More information about the pypy-dev mailing list