tag:blogger.com,1999:blog-3971202189709462152.post5757682347636918027..comments2024-03-11T12:50:02.036+01:00Comments on PyPy Status Blog: PyPy Cape Town Sprint Oct 7th - Oct 21st 2012Carl Friedrich Bolz-Tereickhttp://www.blogger.com/profile/00518922641059511014noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-3971202189709462152.post-29972067255863787492012-09-14T11:04:43.984+02:002012-09-14T11:04:43.984+02:00you could just import sys:
import sys
ispypy = ha...you could just import sys:<br /><br />import sys<br />ispypy = hasattr(sys, "pypy_version_info")ArneBabhttps://www.blogger.com/profile/16449390422848764481noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-46095302326436624502012-09-13T17:12:27.469+02:002012-09-13T17:12:27.469+02:00thanks for the post dear. nice blog. thanks for the post dear. nice blog. how to climbhttp://how-to-climb.comnoreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-76130410628814945082012-09-13T14:32:36.757+02:002012-09-13T14:32:36.757+02:00in order to import StringIO as cStringIO. how to c...in order to import StringIO as cStringIO. how to confirm my script is running pypy? not python ? Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-85093220787580071792012-09-13T14:29:12.681+02:002012-09-13T14:29:12.681+02:00Glad to help :)
The cool part here is that pypy a...Glad to help :)<br /><br />The cool part here is that pypy allows us to replace many C-modules with nicely readable python-code and still get a fast program.<br /><br />And that your custom code gets the same speedups.ArneBabhttps://www.blogger.com/profile/16449390422848764481noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-56684241078111794442012-09-13T14:26:17.476+02:002012-09-13T14:26:17.476+02:00Increase the amount of iterations for even higher ...Increase the amount of iterations for even higher speedups: <br /><br /> text = '1234567890' * 1024 * 256 * 16<br /><br />⇒<br /><br /><br /><br />$ bin/pypy stringiotest.py <br />cStringIO<br />ts 224.367353201<br />ts 140.621050835<br />ts 140.672322035<br />StringIO<br />ts 5.80670285225<br />ts 4.95937395096<br />ts 4.82084798813<br /><br />$ python stringiotest.py <br />cStringIO<br />ts 9.54650998116<br />ts 9.60773801804<br />ts 9.56916093826<br />StringIO<br />ts 47.1465728283<br />ts 47.145359993<br />ts 47.1618230343<br /><br /><br />Interestingly pypy with StringIO is twice as fast as python with cStringIO. But pypy with cStringIO is slow.<br /><br />So pypy with StringIO might still require 2x as much time as python2.6+psyco2. <br /><br />But remember that this compares pure python code on pypy with hand-optimized C-code+psyco.ArneBabhttps://www.blogger.com/profile/16449390422848764481noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-32777936926795752182012-09-13T14:25:59.137+02:002012-09-13T14:25:59.137+02:00thanks, it works with StringIO.thanks, it works with StringIO.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-55190068241081976642012-09-12T16:29:17.402+02:002012-09-12T16:29:17.402+02:00You could try using StringIO instead of cStringIO....You could try using StringIO instead of cStringIO. pypy can optimize that much better.<br /><br />Here’s an adapted example:<br /><br />------ ------ ------<br /><br />import time, StringIO, cStringIO<br /><br />def csio():<br /> text = '1234567890' * 1024 * 256<br /> sio = cStringIO.StringIO()<br /> ts = time.time()<br /> for ch in text: sio.write(ch)<br /> print 'ts', time.time() - ts<br /><br />def nsio():<br /> text = '1234567890' * 1024 * 256<br /> sio = StringIO.StringIO()<br /> ts = time.time()<br /> for ch in text: sio.write(ch)<br /> print 'ts', time.time() - ts<br /><br /><br />print "cStringIO"<br />csio()<br />csio()<br />csio()<br /><br />print "StringIO"<br />nsio()<br />nsio()<br />nsio()<br /><br />------ ------ ------<br /><br />Results for me with pypy 1.9:<br /><br />$ python stringiotest.py <br />cStringIO<br />ts 0.636300086975<br />ts 0.63633108139<br />ts 0.636710882187<br />StringIO<br />ts 3.35502791405<br />ts 3.34557986259<br />ts 3.33949017525<br />$ bin/pypy stringiotest.py <br />cStringIO<br />ts 1.05391597748<br />ts 0.528824090958<br />ts 0.530929803848<br />StringIO<br />ts 0.359623908997<br />ts 0.277186870575<br />ts 0.273662090302Arne Babenhauserheidehttp://draketo.denoreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-55834815481633676352012-09-09T14:31:53.093+02:002012-09-09T14:31:53.093+02:00I found that "cStringIO" is extremely sl...I found that "cStringIO" is extremely slow in pypy1.9 (almost three times slower than python2.7), I'm using a lot of cStringIO in my text parser. here is my benchmark:<br /><br />import time, cStringIO<br /><br />def test1():<br /> text = '1234567890' * 1024 * 256<br /> sio = cStringIO.StringIO()<br /> ts = time.time()<br /> for ch in text: sio.write(ch)<br /> print 'ts', time.time() - ts<br /><br />try: <br /> import psyco<br /> psyco.full()<br />except:<br /> pass<br /><br /><br />test1()<br />test1()<br />test1()<br /><br /># python2.7 0.45s<br /># psyco2 0.26s<br /># pypy-1.9 1.30s<br /><br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-16454350508790946232012-09-07T14:48:11.095+02:002012-09-07T14:48:11.095+02:00Obviously if you don't provide a benchmark we&...Obviously if you don't provide a benchmark we're completely clueless.Maciej Fijalkowskihttps://www.blogger.com/profile/11410841070239382771noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-5148283330455205702012-09-07T12:16:46.011+02:002012-09-07T12:16:46.011+02:00Why pypy is three times slower than python2.6 + ps...Why pypy is three times slower than python2.6 + psyco2 ??<br /><br /># text parser: <br /># python2.7 - 0.94s<br /># python2.7 + cython - 0.73s<br /># pypy1.9 - 0.68s<br /># python2.5 + psyco1.6 - 0.31s<br /># python2.6 + psyco2 - 0.23s<br /><br />"python2.6 + psyco2" is 3.3 times faster than pypy1.9, why ??Anonymousnoreply@blogger.com