where python is slower?
Just
just at xs4all.nl
Thu Feb 6 03:59:42 EST 2003
In article <mailman.1044449190.18425.python-list at python.org>,
"Enrique Palomo" <enrique.palomo at xgs-spain.com> wrote:
> At job, i must work with great size text files (up to 2 Gb)
> I use python cause of its facility to work with strings.
> But python is slower than others programming languages.
>
> It´s not, by the moment, a big problem, but i would like to speed up the
> code with C.
>
> I would like to know where python is slower, reading files, writing, string
> manipulation...
>
> I have try with psyco and the results are unpredictable everytime i run the
> script.
If you're reading the files line by line you need to carefully look at
what idiom you use to do that. If you're using Python2.2, you're
_probably_ best off by doing this:
f = open(...)
for line in f:
...process line...
In earlier Pythons (prabably back to 2.0, not sure) you the equivalent
is:
f = open(...)
for line in f.xreadlines():
...process line...
Using f.readline() one line at a time is likely to be noticably slower,
unless the bottleneck is your actual processing...
Just
More information about the Python-list
mailing list