where python is slower?
claird at lairds.com
Wed Feb 5 16:42:10 CET 2003
In article <Se80a.186428$AA2.7271929 at news2.tin.it>,
Alex Martelli <aleax at aleax.it> wrote:
>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).
I feel compelled to add that there have been many real-life
cases in which custom-coded C-based applications focused on
text manipulation have turned out to be *slower* than their
Python correspondents, because the latter so often employ
Cameron Laird <Cameron at Lairds.com>
More information about the Python-list