list.sort(func) speed

Peter Otten __peter__ at web.de
Sun Aug 31 05:21:59 EDT 2003


Michael Peuser wrote:

> It drove me nearly crazy when I detected that os.path split and join
> operations took even longer than raw disk access in a directory scan
> program....

Now, that was a fast disk :-) I fear, that some data was already in the
cache when your improved version was executed. Please post some sample
code/timings for the unbelieving.

> Please note that all os.path functions are *awfully* slow! If ever
> possible use a nonportable self made scheme.

If ever possible, use a *portable* scheme shipped with the distribution.
Chances are that it is ahead of your ad hoc solution in terms of
correctness. If you have written code that greatly improves on the current
implementations, you might consider submitting a patch...

> (The other issue (decorated sorting) is more relevent of course.)
D'accord. Namely, basename() is not the bottleneck here.

Backslashes-removingly yours,
Peter




More information about the Python-list mailing list