python disk i/o speed
Peter Hansen
peter at engcorp.com
Thu Aug 8 07:44:22 EDT 2002
nnes wrote:
>
> Thanks all of you!
>
> After reading the enlightening comments I came up with a new version.
> It looks nicer too :-).
>
> Jeffs code looked like out of a Cookbook: use re for input and % for
> output on stdio and you have got almost unlimited flexibility, and if
> you understand regular expresions you know exactly what´s going on. It
> was slower of course. Now I wish the print format syntax and the re
> syntax were somehow unified.
>
> The other approaches were similar to mine using split. Some also using
> map and reduce which would be good if I had more than 3 variables. I
> will test it later, but I doubt it will improve the speed.
>
> Unfortunately the speedup is not near I would have expected. From the
> old 36 seconds down to 33 seconds (using python -O). So I am still
> open to suggestions.
Why don't you run the profiler on it and see where the time is
being spent? Random arbitrary optimizations is a waste of developer
time, and generally makes the code less maintainable.
(And Duncan's comments are still highly relevant.)
-Peter
More information about the Python-list
mailing list