where python is slower?

Alex Martelli aleax at aleax.it
Wed Feb 5 08:22:58 EST 2003


Enrique Palomo wrote:
   ...
> I would like to know where python is slower, reading files, writing,
> string manipulation...

None of the above.  File I/O speeds are essentially determined
by your disk, operating system and runtime library (and Python
uses the C runtime library), and string manipulation is quite
well optimized in Python -- it's unlikely, in general, that you
can easily code custom C code to do much better (in a few very
special cases it might be possible, because Python strings are
immutable -- if the specific manipulation you need is, e.g.,
"change the 277th character into a 'K'", then C lets you do
that in-place while Python requires making a new string object).


Alex





More information about the Python-list mailing list