December 25, 2006

Geek

Irony

IronPython is a version of Python written in C# for the .Net platform. It's intended as an embedded scripting language for .Net applications, but can also be used to quickly assemble applications from components written in other .Net languages. Since I'm currently working in both Python and .Net, this is of interest to me, so I downloaded IronPython* and ran my little benchmark.

And then I went and had dinner, and read a book, and read some blogs, and had some ice cream, and then came and posted this. Because IronPython has a leetle performance problem relative to CPython**; or rather, it lacks at least one very important optimisation from CPython. See if you can spot what it is:

SystemCPUClockPythonLoopStringScanTotal
AmeliaCore Duo1.66GHz2.5 (Win)1.2433.1581.0335.434
AmeliaCore Duo1.66GHz2.5 (Win)+Psyco0.0370.4831.1901.710
AmeliaCore Duo1.66GHzIronPython 1.010.6982236.3192.0452239.062

Source code for the benchmark can be found in my earlier post.

* Again; I had it on my old notebook, but that got reformatted and reinstalled at least four times, and in any case I no longer have it.

** The standard version of Python, which is written in C.


The answer: My benchmark does a lot of string concatenation, because Minx does too. But Minx and my benchmark both perform just fine because CPython has a very useful optimisation for its string concatenation.

A naive approach (typical of early Microsoft Basics, for example) would create a new string each time: new_string = old_string + whatever. In my benchmark, though, that would cause an aggregate of about a terabyte of memory traffic. You can see that CPython doesn't use a naive approach, because my notebook doesn't have 300GB/second of memory bandwidth, let alone the 2TB/second indicated by the Psyco results. CPython leaves room at the end of objects for them to grow; it updates the data in place and only copies the object when it runs out of room.

Simple things like that can make a big difference. Like a factor of 5000, in this case.

Posted by: Pixy Misa at 01:57 AM | Comments (37) | Add Comment | Trackbacks (Suck)

1 Seriously stuffed.

Posted by: Andrew at December 26, 2006 08:56 AM (81C4m)

2 Hello. That's very nice site but I've seen this before here:
http://text.inguaro.com/6602bf862513c92ade4ac57f271812d8
6602bf862513c92ade4ac57f271812d8

Posted by: Deven at March 10, 2009 12:44 PM (4NdWV)

3 Hello. That's very nice site but I've seen this before here:
[url]http://bb2.inguaro.com/6602bf862513c92ade4ac57f271812d8[/url]
6602bf862513c92ade4ac57f271812d8

Posted by: Deven at March 10, 2009 12:44 PM (4NdWV)

4 Hello. That's very nice site but I've seen this before here:
[url]http://bb2.inguaro.com/d94c7cfd00b5597f9084d3cc1d76de1a[/url]
d94c7cfd00b5597f9084d3cc1d76de1a

Posted by: Oliver at March 18, 2009 02:29 AM (rC3SE)

5 Hello. That's very nice site but I've seen this before here:
http://text.inguaro.com/d94c7cfd00b5597f9084d3cc1d76de1a
d94c7cfd00b5597f9084d3cc1d76de1a

Posted by: Oliver at March 18, 2009 02:29 AM (rC3SE)

6 Seal
http://babiesindanger.com/games/customized-photos/?Seal
michelle marsh
http://babiesindanger.com/games/customized-photos/?michelle-marsh
Justin Bartha
http://babiesindanger.com/games/customized-photos/?Justin-Bartha
Jordin Sparks
http://babiesindanger.com/games/customized-photos/?Jordin-Sparks
Brooklyn Beckham
http://babiesindanger.com/games/customized-photos/?Brooklyn-Beckham
Liliane Ferrarezi
http://babiesindanger.com/games/customized-photos/?Liliane-Ferrarezi
melanie brown
http://babiesindanger.com/games/customized-photos/?melanie-brown
Cindy Crawford
http://babiesindanger.com/games/customized-photos/?Cindy-Crawford
Mariah Carey
http://babiesindanger.com/games/customized-photos/?Mariah-Carey
Rihanna
http://babiesindanger.com/games/customized-photos/?Rihanna

Posted by: Kai at April 22, 2009 05:24 AM (qGSJx)

7 prick photo
http://basic.thedci.org/games/photos-kisses/?prick-photo
industrial accident photo
http://basic.thedci.org/games/photos-kisses/?industrial-accident-photo
indian art photo
http://basic.thedci.org/games/photos-kisses/?indian-art-photo
salli richardson photo
http://basic.thedci.org/games/photos-kisses/?salli-richardson-photo
virgin island photo
http://basic.thedci.org/games/photos-kisses/?virgin-island-photo
photo universal
http://basic.thedci.org/games/photos-kisses/?photo-universal
henry t. sampson photo
http://basic.thedci.org/games/photos-kisses/?henry-t.-sampson-photo
canadian landscape photo
http://basic.thedci.org/games/photos-kisses/?canadian-landscape-photo
photo editing softwares
http://basic.thedci.org/games/photos-kisses/?photo-editing-softwares
photo of ingrown hair
http://basic.thedci.org/games/photos-kisses/?photo-of-ingrown-hair

Posted by: Seth at April 25, 2009 10:36 PM (ygFmi)

Hide Comments | Add Comment






Processing 0.01, elapsed 0.0159 seconds.
16 queries taking 0.0114 seconds, 29 records returned.
Page size 13 kb.
Powered by Minx 0.8 beta.