list.sort(func) speed

Peter Otten __peter__ at web.de
Sun Aug 31 08:20:46 EDT 2003


mackstann wrote:

> So basename() is not the bottleneck, but accounts for perhaps 1/6th of
> the time needed overall.  I just wonder if the other 5/6th could be
> reduced further by doing something that I'm not thinking of.

I've tinkered with your code a bit and could not come up with something
faster :-(

However, your songs seem to correspond to files, so why not store them in
your list as (filename, directory) or (filename, fullpath) tuples in the
first place?

Personally, I would go with a Song class, where the artist, length etc.
could successively be added, but that would rather be trading speed for
features...

Peter




More information about the Python-list mailing list