Hai Alex,<div><br></div><div>Thanks for your reply and making me understand about PyPy Jit.</div><div><br></div><div>Some more query on PyPy;</div><div><br></div><div>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.</div>
<div> So what might be the reason for this that PyPy took more time than Python ?</div><div><br></div><div>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 ? )</div>
<div> </div><div>Thanking you,</div><div>Sasikanth</div><div><br></div><div>On Fri, May 18, 2012 at 10:41 AM, Alex Gaynor <span dir="ltr"><<a href="mailto:alex.gaynor@gmail.com" target="_blank">alex.gaynor@gmail.com</a>></span> wrote:</div>
<div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><br><div class="gmail_quote"><div><div class="h5">On Fri, May 18, 2012 at 12:58 AM, Sasikanth Eda <span dir="ltr"><<a href="mailto:sasikanth.ece@gmail.com" target="_blank">sasikanth.ece@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Hai All,<div><br></div><div>In trails of finding the execution time lapse between Python and PyPy , its proved that PyPy is slower than Python.</div><div><br></div><div>Here are the trials done ;</div><div><br></div><div>
<b>Step-1: Written a Python code that uses repeated os.rename()</b></div>
<div><b><br></b></div><div><b>code: (file name : rename.py)</b></div><div><div><i> #!/usr/bin/env python</i></div><div><i><br></i></div><div><i> import os</i></div><div><i> import sys</i></div>
<div><i><br></i></div><div><i> os.chdir("/opt/pypy-1.8/bin")</i></div><div><i> print "Rename count -1 (a1 -> a2)"</i></div><div><i> os.rename("a1","a2")</i></div>
<div><i> print "Rename count -2 (a2 -> a3)"</i></div><div><i> os.rename("a2","a3")</i></div><div><i> print "Rename count -3 (a3 -> a4)"</i></div>
<div><i> os.rename("a3","a4")</i></div><div><i> print "Rename count -4 (a4 -> a5)"</i></div><div><i> os.rename("a4","a5")</i></div><div>
<i> print "Rename count -5 (a5 -> a6)"</i></div>
<div><i> os.rename("a5","a6")</i></div><div><i> print "Rename count -6 (a6 -> a7)"</i></div><div><i> os.rename("a6","a7")</i></div><div>
<i> print "Rename count -7 (a7 -> a8)"</i></div>
<div><i> os.rename("a7","a8")</i></div><div><i> print "Rename count -8 (a8 -> a9)"</i></div><div><i> os.rename("a8","a9")</i></div><div>
<i> print "Rename count -9 (a9 -> a0)"</i></div>
<div><i> os.rename("a9","a0")</i></div><div><i> print "Rename count -10 (a0 -> B0)"</i></div><div><i> os.rename("a0","B0")</i></div><div>
<i><br>
</i></div><div><b>Step-2: Observed Execution time with Python 2.7</b></div><div><div style="font-weight:bold"><i><br></i></div><div style="font-weight:bold"><i> [root@Manojkiran bin]# time python rename.py </i></div>
<div><i> Rename count -1 (a1 -> a2)</i></div><div><i> Rename count -2 (a2 -> a3)</i></div><div><i> Rename count -3 (a3 -> a4)</i></div><div><i> Rename count -4 (a4 -> a5)</i></div>
<div><i> Rename count -5 (a5 -> a6)</i></div><div><i> Rename count -6 (a6 -> a7)</i></div><div><i> Rename count -7 (a7 -> a8)</i></div><div><i> Rename count -8 (a8 -> a9)</i></div>
<div><i> Rename count -9 (a9 -> a0)</i></div><div><i> Rename count -10 (a0 -> B0)</i></div><div style="font-weight:bold"><i><br></i></div><div style="font-weight:bold"><i> real<span style="white-space:pre-wrap">        </span>0m0.031s</i></div>
<div style="font-weight:bold"><i> user<span style="white-space:pre-wrap">        </span>0m0.021s</i></div><div style="font-weight:bold"><i> sys<span style="white-space:pre-wrap">        </span>0m0.010s</i></div>
<div style="font-weight:bold"><br></div></div><div style="font-weight:bold">Step-3:<b> Observed Execution time with PyPy 1.8</b></div></div><div style="font-weight:bold"><b><br></b></div><div><div style="font-weight:bold">
[root@Manojkiran bin]# time ./pypy rename.py </div><div><i> ./pypy: /usr/local/ssl/lib/libssl.so.0.9.8: no version information available (required by ./pypy)</i></div><div><i> ./pypy: /usr/local/ssl/lib/libcrypto.so.0.9.8: no version information available (required by ./pypy)</i></div>
<div><i> Rename count -1 (a1 -> a2)</i></div><div><i> Rename count -2 (a2 -> a3)</i></div><div><i> Rename count -3 (a3 -> a4)</i></div><div><i> Rename count -4 (a4 -> a5)</i></div>
<div><i> Rename count -5 (a5 -> a6)</i></div><div><i> Rename count -6 (a6 -> a7)</i></div><div><i> Rename count -7 (a7 -> a8)</i></div><div><i> Rename count -8 (a8 -> a9)</i></div>
<div><i> Rename count -9 (a9 -> a0)</i></div><div><i> Rename count -10 (a0 -> B0)</i></div><div style="font-weight:bold"><br></div><div style="font-weight:bold"> real<span style="white-space:pre-wrap">        </span>0m0.054s</div>
<div style="font-weight:bold"> user<span style="white-space:pre-wrap">        </span>0m0.036s</div><div style="font-weight:bold"> sys<span style="white-space:pre-wrap">        </span>0m0.016s</div>
</div><div><b><br></b></div>
<div><b>Step-4: Written a Python code that uses repeated os.link()</b></div><div><b><br></b></div><div><b>code: (file name : link.py)</b></div><div><div> <i> #!/usr/bin/env python</i></div><div><i><br></i></div>
<div><i> import os</i></div><div><i> import sys</i></div><div><i><br></i></div><div><i> os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l0")</i></div><div><i> print "Linked count -1 (l0 -> lo)"</i></div>
<div><i> os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l1")</i></div>
<div><i> print "Linked count -2 (l0 -> l1)"</i></div><div><i> os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l2")</i></div><div><i> print "Linked count -3 (l0 -> l2)"</i></div>
<div><i> os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l3")</i></div>
<div><i> print "Linked count -4 (l0 -> l3)"</i></div><div><i> os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l4")</i></div><div><i> print "Linked count -5 (l0 -> l4)"</i></div>
<div><i> os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l5")</i></div>
<div><i> print "Linked count -6 (l0 -> l5)"</i></div><div><i> os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l6")</i></div><div><i> print "Linked count -7 (l0 -> l6)"</i></div>
<div><i> os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l7")</i></div>
<div><i> print "Linked count -8 (l0 -> l7)"</i></div><div><i> os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l8")</i></div><div><i> print "Linked count -9 (l0 -> l8)"</i></div>
<div><i> os.link("/opt/pypy-1.8/bin/l0","/opt/pypy-1.8/bin/test/l9")</i></div>
<div><i> print "Linked count -10 (l0 -> l9)"</i></div><div><br></div><div><div><div><b>Step-5: Observed Execution time with Python 2.7</b></div><div><div style="font-weight:bold"><i><br></i></div><div style="font-weight:bold">
<i> [root@Manojkiran bin]# time python link.py </i></div><div><i> Linked count -1 (l0 -> l0)</i></div><div><i> </i><i>Linked</i><i> count -2 (l0 -> l1)</i></div><div><i> </i><i>Linked</i><i> count -3 (l0 -> l2)</i></div>
<div><i> </i><i>Linked</i><i> count -4 (l0 -> l3)</i></div><div><i> </i><i>Linked</i><i> count -5 (l0 -> l4)</i></div><div><i> </i><i>Linked</i><i> count -6 (l0 -> l5)</i></div><div>
<i> </i><i>Linked</i><i> count -7 (l0 -> l6)</i></div><div><i> </i><i>Linked</i><i> count -8 (l0 -> l7)</i></div><div><i> </i><i>Linked</i><i> count -9 (l0 -> l8)</i></div><div><i> </i><i>Linked</i><i> count -10 (l0 -> l9)</i></div>
<div style="font-weight:bold"><i><br></i></div><div style="font-weight:bold"><i> real<span style="white-space:pre-wrap">        </span>0m0.028s</i></div><div style="font-weight:bold"><i> user<span style="white-space:pre-wrap">        </span>0m0.020s</i></div>
<div style="font-weight:bold"><i> sys<span style="white-space:pre-wrap">        </span>0m0.008s</i></div><div style="font-weight:bold"><br></div></div><div style="font-weight:bold">Step-6:<b> Observed Execution time with PyPy 1.8</b></div>
</div><div style="font-weight:bold"><b><br></b></div><div><div style="font-weight:bold"> [root@Manojkiran bin]# time ./pypy link.py </div><div><i> ./pypy: /usr/local/ssl/lib/libssl.so.0.9.8: no version information available (required by ./pypy)</i></div>
<div><i> ./pypy: /usr/local/ssl/lib/libcrypto.so.0.9.8: no version information available (required by ./pypy)</i></div><div><div><i> Linked count -1 (l0 -> l0)</i></div><div><i> </i><i>Linked</i><i> count -2 (l0 -> l1)</i></div>
<div><i> </i><i>Linked</i><i> count -3 (l0 -> l2)</i></div><div><i> </i><i>Linked</i><i> count -4 (l0 -> l3)</i></div><div><i> </i><i>Linked</i><i> count -5 (l0 -> l4)</i></div><div>
<i> </i><i>Linked</i><i> count -6 (l0 -> l5)</i></div><div><i> </i><i>Linked</i><i> count -7 (l0 -> l6)</i></div><div><i> </i><i>Linked</i><i> count -8 (l0 -> l7)</i></div><div><i> </i><i>Linked</i><i> count -9 (l0 -> l8)</i></div>
<div><i> </i><i>Linked</i><i> count -10 (l0 -> l9)</i></div></div><div><i><br></i></div><div style="font-weight:bold"> real<span style="white-space:pre-wrap">        </span>0m0.056s</div>
<div style="font-weight:bold"> user<span style="white-space:pre-wrap">        </span>0m0.032s</div><div style="font-weight:bold"> sys<span style="white-space:pre-wrap">        </span>0m0.023s</div>
</div></div><div><br></div><div>Hence in my understanding Python is better in terms of execution time when compared with PyPy.</div><div><br></div><div>Kindly suggest me if my trails are proper and why PyPy failed to achieve better speed then PyPy ?</div>
<div><br></div><div>Is this a know issue or whether we have any fix for this ?</div><div><br></div><div>Thanking you,</div><span><font color="#888888"><div>-- </div>Sasikanth<br><br><br><br>
</font></span></div>
<br></div></div>_______________________________________________<br>
pypy-dev mailing list<br>
<a href="mailto:pypy-dev@python.org" target="_blank">pypy-dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/pypy-dev" target="_blank">http://mail.python.org/mailman/listinfo/pypy-dev</a><br>
<br></blockquote></div><br>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.<span class="HOEnZb"><font color="#888888"><br>
<br>Alex<br clear="all"><br>-- <br>"I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire)<br>"The people's good is the highest law." -- Cicero<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div><br><br><br>
</div>