Ted Leung on the air
Ted Leung on the air: Open Source, Java, Python, and ...
Ted Leung on the air: Open Source, Java, Python, and ...
Sun, 16 Mar 2003
Fast Python
Today I read Skip Montanaro's
Python Performance Tips. This really helped me get an idea of the things that impact performance in Python programs.
It seems that both the languages that I use regularly, Java and Python have issues with string concatenation. In both languages, the thing that seems to be the obvious way to concatenate strings is also the low performance way. There's so much string handling going on in the world that I just don't understand why strings are so broken this way. Seems like there hasn't been a lot of attention paid to strings, and probably only C++ programmers are aware of Hans J. Boehm's work on Ropes.
I was happy to find that for loops are not as fast as using map, but disappointed because list comprehensions are syntactic sugar for for loops and therefore also slow.
I was also surprised to find out that import statements are executed, although I guess if I had thought about it for a minute I would have realized that. Same for using calls like
[23:34] |
[computers/programming/python] |
# |
TB |
F |
G |
0 Comments |
string.upper
.
At least I'm on the way to building a mental model of performance for Python.
You can subscribe to an RSS feed of the comments for this blog:
Add a comment here:
You can use some HTML tags in the comment text:
To insert a URI, just type it -- no need to write an anchor tag.
Allowable html tags are:
You can also use some Wiki style:
URI => [uri title]
<em> => _emphasized text_
<b> => *bold text*
Ordered list => consecutive lines starting spaces and an asterisk
To insert a URI, just type it -- no need to write an anchor tag.
Allowable html tags are:
<a href>
, <em>
, <i>
, <b>
, <blockquote>
, <br/>
, <p>
, <code>
, <pre>
, <cite>
, <sub>
and <sup>
.You can also use some Wiki style:
URI => [uri title]
<em> => _emphasized text_
<b> => *bold text*
Ordered list => consecutive lines starting spaces and an asterisk