tag:blogger.com,1999:blog-68730239358084672.post4059993278545998936..comments2026-04-13T04:00:41.271-07:00Comments on Technical Discovery: Speeding up Python AgainTravis Oliphanthttp://www.blogger.com/profile/04514536132317233988noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-68730239358084672.post-51512338012081326792012-03-26T13:56:41.506-07:002012-03-26T13:56:41.506-07:00I’m usually looking about the internet for content...I’m usually looking about the internet for content articles that can help me.<br />Thank you. It is extremely helpful for me.<br />would you mind updating your blog with more information?<br />source: www.wbupdates.comfarhanhttps://www.blogger.com/profile/08294710740842841481noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-14696014120828682402011-11-17T04:58:21.492-08:002011-11-17T04:58:21.492-08:00Thanks for sharing your info. I really appreciate ...Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.<br /><a href="http://WINDOWSPHONE7DEVELOPMENT.NET" rel="nofollow"> WINDOWS PHONE 7 DEVELOPMENT</a>Laurainehttps://www.blogger.com/profile/13785227157224255176noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-75142877593827422542011-10-27T05:51:13.860-07:002011-10-27T05:51:13.860-07:00Hi, I was wondering why C++/Weave turned out to be...Hi, I was wondering why C++/Weave turned out to be so much slower than Fortran in your tests. But there are two major differences:<br />* the Weave code uses functions for indexing the array, probably including boundary checks etc.<br />* the Fortran code is compiled with optimizations<br /><br />After optimizing the code, Weave beats Fortran on my machine now:<br />Looped Fortran: 2.050914 seconds<br />Vectorized Fortran: 1.505481 seconds<br />Weave: 1.351250 seconds<br />(Weave: 0.716219 seconds, with openmp)<br /><br />Some notes:<br />* This test-bench does not call weave-update before running the actual timing test, which means Weave will be slow when you use it for the first time as it needs to compile and cache the code first. So you have to ignore the first test.<br />* The multi-core aware solution is easy! (@MySchizuBuddy) Just added a single openmp line and some compiler options and the calculation completed almost 2x faster on my AMD quad core. Change &quot;fno-openmp&quot; to &quot;fopenmp&quot; for testing the openmp solution.<br />* When changing compiler flags, like &quot;fopenmp&quot;, be aware that Weave does NOT recompile the code, as the code-string itself did not change. In order to test different compiler flags, you have to clear your code cache (~/.python27_compiled).<br />* There is a bug in gcc that prevents vectorization when openmp is enabled http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46032<br />You will notice this when looking at the verbose gcc output. So once this bug is fixed, one could check out the fully optimized, vectorized, parallelized calculation :D.<br /><br />And this is the code: http://pastebin.com/MNfhWjSmpedahttps://www.blogger.com/profile/03725405805932961102noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-63868002325730756282011-09-24T05:45:00.021-07:002011-09-24T05:45:00.021-07:00is either of these solution multi-core awareis either of these solution multi-core awareMySchizoBuddyhttps://www.blogger.com/profile/10128941462646510194noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-91411124472224925312011-09-20T14:23:14.490-07:002011-09-20T14:23:14.490-07:00Hi, could anyone include a comparison between Weav...Hi, could anyone include a comparison between Weave and Instant? Thanks!Guilherme Ferrarihttps://www.blogger.com/profile/06908539902966807526noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-48435047471503364982011-07-09T02:50:28.201-07:002011-07-09T02:50:28.201-07:00compiling laplace2.py using &#39;shedskin -b&#39; ...compiling laplace2.py using &#39;shedskin -b&#39; gives a speedup of about a 100 times on my PC (http://shedskin.googlecode.com).srepmubhttps://www.blogger.com/profile/15831320699731673389noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-1712769414724820132011-07-07T11:12:02.209-07:002011-07-07T11:12:02.209-07:00If you run laplace_for.f90, make sure you change N...If you run laplace_for.f90, make sure you change N to 150, and use for_update2 (vectorized) function in there (for_update1 is default, which is a simple loop). Then I get 0.500s on my computer. For NumPy solution, I get 5.56s, which seems comparable to your timings. As such, doing &quot;pure vectorized Fortran&quot; (0.5s) seems to speed up the &quot;vectorized Fortran&quot; (1.42s) timing almost three times. (f2py fails to compile on my computer due to some missing main() routine, so I can&#39;t easily check it myself.)<br /><br />Let me know if someone can reproduce my pure Fortan timing, i.e. being 10x faster than NumPy. So that I don&#39;t jump to conclusions too fast.Anonymoushttps://www.blogger.com/profile/02845032202161204018noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-78641656358285449692011-07-07T00:48:42.870-07:002011-07-07T00:48:42.870-07:00Hi Travis, you should also mention, that the loop ...Hi Travis, you should also mention, that the loop and vectorized loop are *not* mathematically equivalent, as is shown by printing for example the sum of the values of the array. You would need to greatly increase the number of iterations. Eventually it converges to the same values though, but not for Niter=8000. This was confusing to me, when I was testing the Fortran solution.<br /><br />Another note is that it seems that the pure Fortran solution is still quite a bit faster than Python + f2py + f90 solution. You might say that the main loop should always be in Python to be fair, but I would argue that since pypy can do some magic (?) optimizations anyway even for the main loop, it makes sense to really see what the maximum speed is. One can just run the laplace_for.f90 example in scipy/speed repository.Anonymoushttps://www.blogger.com/profile/02845032202161204018noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-17285270400179301982011-07-05T10:54:24.442-07:002011-07-05T10:54:24.442-07:00For what it&#39;s worth if I switch this to use ar...For what it&#39;s worth if I switch this to use array.array(&quot;d&quot;, [0.0]) * N when creating the arrays it goes about 60% faster on my machine. As Ismael mentioned this will eventually be handled basically automatically.Alexhttps://www.blogger.com/profile/14054821112394577330noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-52400927839604043492011-07-05T10:29:46.844-07:002011-07-05T10:29:46.844-07:00Thanks for posting the code on github. The PyPy r...Thanks for posting the code on github. The PyPy results are amazing. At some level this changes everything.Prabhu Ramachandranhttps://www.blogger.com/profile/02222896794693014723noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-80732407806446677942011-07-05T07:27:40.284-07:002011-07-05T07:27:40.284-07:00You should add Cython without numpy. There is wor...You should add Cython without numpy.<br /><br />There is work going on in PyPy to optimize lists of the same type of objects to be as fast as arrays, so you can expect further speed up in the future :)Ismaelhttps://www.blogger.com/profile/10313478883551744679noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-43077721472001533722011-07-05T05:41:43.723-07:002011-07-05T05:41:43.723-07:00Hi Travis. I&#39;ve been going through a similar t...Hi Travis. I&#39;ve been going through a similar test after my EuroPython High Performance Python tutorial, I&#39;ve written up a v0.1 doc here:<br />http://ianozsvald.com/2011/06/29/high-performance-python-tutorial-v0-1-from-my-4-hour-tutorial-at-europython-2011/<br />and v0.2 should be in the works in a couple of weeks. I&#39;ll be taking Maciej&#39;s advice of trying arrays in PyPy (and hopefully testing the micronumpy lib too). I&#39;m impressed (as you are) with the improvements that the PyPy team are bringing out! The trunk version is even faster than the official v1.5.<br />Ian.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-3366502800309157962011-07-05T04:17:51.616-07:002011-07-05T04:17:51.616-07:00Does the impressive performance of PyPy suggest th...Does the impressive performance of PyPy suggest that there may be value in a pure Python NumPy? It would run on Iron Python!<br /><br />RichardRichard Lincolnhttps://www.blogger.com/profile/08881956924414691485noreply@blogger.comtag:blogger.com,1999:blog-68730239358084672.post-5376087347306047312011-07-05T00:08:38.531-07:002011-07-05T00:08:38.531-07:00You would get much better performance in PyPy if y...You would get much better performance in PyPy if you&#39;ve used numpy arrays or array.array instead of list of lists.<br /><br />Also, for obscure reasons a while loop is a tiny bit faster than a for i in xrange(..) one.<br /><br />Cheers,<br />fijalMaciej Fijalkowskihttps://www.blogger.com/profile/11410841070239382771noreply@blogger.com