[Python-ideas] __sort__ special member

Devin Jeanpierre jeanpierreda at gmail.com
Sun Jul 22 03:08:50 CEST 2012


On Fri, Jul 20, 2012 at 2:29 PM, Mark Adam <dreamingforward at gmail.com> wrote:
> Sorry, I'll tone down my words.  But this makes more sense than sort() as a
> built-in.  In theory, sort is for collections, not just any object.  So it
> could belong to an abstract collections base type.   This would allow users
> to select lexical orderings, for example, rather than ASCII.  It seems
> strange that no one thought of it before(it that true?).

FWIW the sort method (as in list.sort()) is polymorphic, just nobody
bothers implementing it.

And how many interesting specializations are there? At best I can only
think of linear-time sorts, but it's pretty rare you'll know your
collection only contains discrete values.

-- Devin



More information about the Python-ideas mailing list