I’m pretty confused about the results I’m getting from a little python test involving len() on strings. Since strings are immutable, I was wondering what happens when len() is called, and what performance considerations I may need to keep in mind. I figure if it was immutable, calls to len() might get cached, and there may be very little performance impact. However, what I found was that over 1 million iterations, twice as many len() calls on a string is roughly 3 times slower than an iteration with only one call. When I called the string’s __len__() method instead, the two are much more comparable, and the one with a single call actually took more time than when calling len(). Weird. Can anyone further enlighten me? Perhaps my testing method is bad (I know it’s not a very good test… I’m just doing it because I can’t sleep at the moment.)
testing stuff
testing things out right now.... be patient pleasePages
Archives
-
Blog Stats
- 15,213 somethings
My Bookmarks- asyd’s blog » Using it’s all text on Mac OS X
- Closure Tools - Google Code
- Ruby on Rails guides
- Ruby 1.8.4
- Ruby Standard Library Documentation
- Ruby Tutorial: Ruby Study Notes - Best Ruby Guide, Ruby Tutorial
- Ruby on Rails: Documentation
- Applications and libraries/Web programming - HaskellWiki
- What You Should Know About the CDC's 2002 Study on Marriage and Cohabitation
- Statistics on Cohabitation
a