[pypy-dev] PyPy proved slower than Python when used os.rename and os.link [ Suggest how to get rid of this ]
Sasikanth Eda
sasikanth.ece at gmail.com
Fri May 18 07:42:44 CEST 2012
Hai Alex,
Thanks for your reply and making me understand about PyPy Jit.
Some more query on PyPy;
1. In my trails I agree that I don't have loops in my program so PyPy is
not able to optimize it. But it should at least should give me the same
execution time as when executed with python.
So what might be the reason for this that PyPy took more time than
Python ?
2. Suppose assume a condition where we have a lot of loops and function
calls in a python program and it is called by several independent processes
(a typical cgi-model). Then what could be the thought is we use PyPy for
such programs (i.e in specific whether are we going to get any performance
changes when compared with python ? )
Thanking you,
Sasikanth
On Fri, May 18, 2012 at 10:41 AM, Alex Gaynor <alex.gaynor at gmail.com> wrote:
>
>
> On Fri, May 18, 2012 at 12:58 AM, Sasikanth Eda <sasikanth.ece at gmail.com>wrote:
>
>> Hai All,
>>
>> In trails of finding the execution time lapse between Python and PyPy ,
>> its proved that PyPy is slower than Python.
>>
>> Here are the trials done ;
>>
>> *Step-1: Written a Python code that uses repeated os.rename()*
>> *
>> *
>> *code: (file name : rename.py)*
>> * #!/usr/bin/env python*
>> *
>> *
>> * import os*
>> * import sys*
>> *
>> *
>> * os.chdir("/opt/pypy-1.8/bin")*
>> * print "Rename count -1 (a1 -> a2)"*
>> * os.rename("a1","a2")*
>> * print "Rename count -2 (a2 -> a3)"*
>> * os.rename("a2","a3")*
>> * print "Rename count -3 (a3 -> a4)"*
>> * os.rename("a3","a4")*
>> * print "Rename count -4 (a4 -> a5)"*
>> * os.rename("a4","a5")*
>> * print "Rename count -5 (a5 -> a6)"*
>> * os.rename("a5","a6")*
>> * print "Rename count -6 (a6 -> a7)"*
>> * os.rename("a6","a7")*
>> * print "Rename count -7 (a7 -> a8)"*
>> * os.rename("a7","a8")*
>> * print "Rename count -8 (a8 -> a9)"*
>> * os.rename("a8","a9")*
>> * print "Rename count -9 (a9 -> a0)"*
>> * os.rename("a9","a0")*
>> * print "Rename count -10 (a0 -> B0)"*
>> * os.rename("a0","B0")*
>> *
>> *
>> *Step-2: Observed Execution time with Python 2.7*
>> *
>> *
>> * [root at Manojkiran bin]# time python rename.py *
>> * Rename count -1 (a1 -> a2)*
>> * Rename count -2 (a2 -> a3)*
>> * Rename count -3 (a3 -> a4)*
>> * Rename count -4 (a4 -> a5)*
>> * Rename count -5 (a5 -> a6)*
>> * Rename count -6 (a6 -> a7)*
>> * Rename count -7 (a7 -> a8)*
>> * Rename count -8 (a8 -> a9)*
>> * Rename count -9 (a9 -> a0)*
>> * Rename count -10 (a0 -> B0)*
>> *
>> *
>> * real 0m0.031s*
>> * user 0m0.021s*
>> * sys 0m0.010s*
>>
>> Step-3:* Observed Execution time with PyPy 1.8*
>> *
>> *
>> [root at Manojkiran bin]# time ./pypy rename.py
>> * ./pypy: /usr/local/ssl/lib/libssl.so.0.9.8: no version
>> information available (required by ./pypy)*
>> * ./pypy: /usr/local/ssl/lib/libcrypto.so.0.9.8: no version
>> information available (required by ./pypy)*
>> * Rename count -1 (a1 -> a2)*
>> * Rename count -2 (a2 -> a3)*
>> * Rename count -3 (a3 -> a4)*
>> * Rename count -4 (a4 -> a5)*
>> * Rename count -5 (a5 -> a6)*
>> * Rename count -6 (a6 -> a7)*
>> * Rename count -7 (a7 -> a8)*
>> * Rename count -8 (a8 -> a9)*
>> * Rename count -9 (a9 -> a0)*
>> * Rename count -10 (a0 -> B0)*
>>
>> real 0m0.054s
>> user 0m0.036s
>> sys 0m0.016s
>> *
>> *
>> *Step-4: Written a Python code that uses repeated os.link()*
>> *
>> *
>> *code: (file name : link.py)*
>> * #!/usr/bin/env python*
>> *
>> *
>> * import os*
>> * import sys*
>> *
>> *
>> * os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l0")*
>> * print "Linked count -1 (l0 -> lo)"*
>> * os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l1")*
>> * print "Linked count -2 (l0 -> l1)"*
>> * os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l2")*
>> * print "Linked count -3 (l0 -> l2)"*
>> * os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l3")*
>> * print "Linked count -4 (l0 -> l3)"*
>> * os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l4")*
>> * print "Linked count -5 (l0 -> l4)"*
>> * os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l5")*
>> * print "Linked count -6 (l0 -> l5)"*
>> * os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l6")*
>> * print "Linked count -7 (l0 -> l6)"*
>> * os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l7")*
>> * print "Linked count -8 (l0 -> l7)"*
>> * os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l8")*
>> * print "Linked count -9 (l0 -> l8)"*
>> * os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l9")*
>> * print "Linked count -10 (l0 -> l9)"*
>>
>> *Step-5: Observed Execution time with Python 2.7*
>> *
>> *
>> * [root at Manojkiran bin]# time python link.py *
>> * Linked count -1 (l0 -> l0)*
>> * **Linked** count -2 (l0 -> l1)*
>> * **Linked** count -3 (l0 -> l2)*
>> * **Linked** count -4 (l0 -> l3)*
>> * **Linked** count -5 (l0 -> l4)*
>> * **Linked** count -6 (l0 -> l5)*
>> * **Linked** count -7 (l0 -> l6)*
>> * **Linked** count -8 (l0 -> l7)*
>> * **Linked** count -9 (l0 -> l8)*
>> * **Linked** count -10 (l0 -> l9)*
>> *
>> *
>> * real 0m0.028s*
>> * user 0m0.020s*
>> * sys 0m0.008s*
>>
>> Step-6:* Observed Execution time with PyPy 1.8*
>> *
>> *
>> [root at Manojkiran bin]# time ./pypy link.py
>> * ./pypy: /usr/local/ssl/lib/libssl.so.0.9.8: no version
>> information available (required by ./pypy)*
>> * ./pypy: /usr/local/ssl/lib/libcrypto.so.0.9.8: no version
>> information available (required by ./pypy)*
>> * Linked count -1 (l0 -> l0)*
>> * **Linked** count -2 (l0 -> l1)*
>> * **Linked** count -3 (l0 -> l2)*
>> * **Linked** count -4 (l0 -> l3)*
>> * **Linked** count -5 (l0 -> l4)*
>> * **Linked** count -6 (l0 -> l5)*
>> * **Linked** count -7 (l0 -> l6)*
>> * **Linked** count -8 (l0 -> l7)*
>> * **Linked** count -9 (l0 -> l8)*
>> * **Linked** count -10 (l0 -> l9)*
>> *
>> *
>> real 0m0.056s
>> user 0m0.032s
>> sys 0m0.023s
>>
>> Hence in my understanding Python is better in terms of execution time
>> when compared with PyPy.
>>
>> Kindly suggest me if my trails are proper and why PyPy failed to achieve
>> better speed then PyPy ?
>>
>> Is this a know issue or whether we have any fix for this ?
>>
>> Thanking you,
>> --
>> Sasikanth
>>
>>
>>
>>
>> _______________________________________________
>> pypy-dev mailing list
>> pypy-dev at python.org
>> http://mail.python.org/mailman/listinfo/pypy-dev
>>
>>
> PyPy's JIT works by optimizing loops and functions that are frequently
> run, this generally means your code needs to run at least .5 seconds for
> the JIT to kick in and show benefits. Your code contains no loops for the
> JIT to optimize.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right
> to say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
> "The people's good is the highest law." -- Cicero
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20120518/e83fc224/attachment.html>
More information about the pypy-dev
mailing list