[Python-Dev] Optimizing list.sort() by checking type in advance

Chris Angelico rosuav at gmail.com
Mon Oct 10 17:34:38 EDT 2016


On Tue, Oct 11, 2016 at 7:42 AM, Elliot Gorokhovsky
<elliot.gorokhovsky at gmail.com> wrote:
> ChrisA suggested I also try "make test" or something to get a more realistic
> benchmark. I will do that once I implement this as a patch, right now it's
> an extension module that subclasses list, so I can't just drop it into
> existing code without modification.

Oh, okay. If it's done that way, there's (in a way) a guarantee that
it won't worsen anything, because you have to explicitly request the
new behaviour. So if you KNOW that you're going to be doing a ton of
string-only sorting, you can call on this new list subclass, and if
you're not, you simply don't.

ChrisA


More information about the Python-Dev mailing list