We just found something strange that is going on with the test that we had posted.

Due to Amaury's suspicion we started looking into PyPy's I/O speed. It turns out it is more or less the same speed as Python's:

<<<<
f=open("pypytesting", "w+b")
mylist = str(["qwerty"] * 100)

for i in xrange(1000000):
        f.write(mylist)
>>>>

Running at:
        CPython 2.7.3: 12.563 sec
        PyPy nightly:    12.492 total sec


The previous code that we had posted (you can see it in previous email) does a:
""
for i in xrange(1000000):
        cPickle.dump(mylist, f,1)
""

And runs at:
        CPython 2.7.3:  13.114 sec
        PyPy nightly:    29.239 sec

If we change previous code to write in another equivalent way:
""
for i in xrange(1000000):
        f.write(cPickle.dumps(mylist,1))
""

Then the times are the same between CPython and PyPy:

Cpython 2.7.3: 12.802 sec
PyPy nightly:    12.181 sec

Why is there such a huge speed difference between cPickle.dump( ... f) and f.write(cPickle.dumps(...)) ?

Kind regards.

l.

On 03/07/13 19:16, Amaury Forgeot d'Arc wrote:

2013/7/3 Eleytherios Stamatogiannakis <[email protected]
<mailto:[email protected]>>

    Hello,

    We also found a case where PyPy is 2x slower than CPython. The
    following code:


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.

Note: with pypy, io.open() is even slower :-(

    <<<<

    import cPickle

    fileIter=open("pypytesting", "w+b")
    mylist = ["qwerty"] * 100

    for i in xrange(1000000):
             cPickle.dump(mylist, fileIter,1)

     >>>>

    Runs at:
             CPython 2.7.3:  13.114 sec
             PyPy nightly:    29.239 sec

    [Warning: it'll produce a file (pypytesting) that is 205 MB in size]

    Kind regards,

    lefteris.
    _________________________________________________
    pypy-dev mailing list
    [email protected] <mailto:[email protected]>
    http://mail.python.org/__mailman/listinfo/pypy-dev
    <http://mail.python.org/mailman/listinfo/pypy-dev>




--
Amaury Forgeot d'Arc

_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to