copysort patch, was RE: [Python-Dev] inline sort option

Alex Martelli aleaxit at yahoo.com
Tue Oct 28 11:42:39 EST 2003


On Tuesday 28 October 2003 03:01 pm, Phillip J. Eby wrote:
> At 05:29 AM 10/28/03 -0500, Raymond Hettinger wrote:
> >   inlinesort()   # immediately clear how it is different from sort()
> >   sortedcopy()   # clear that it makes a copy and does a sort
> >   newsorted()    # appropriate for a class method constructor
>
> +1 on sortedcopy(), especially if it's usable as a method, e.g.
> myList.sortedcopy().  (Note that that doesn't exclude it also being spelled
> as 'list.sortedcopy(myList)'.)

Please explain how it might work when the argument to list.sortedcopy is *NOT*
an instance of type list, but rather a completely general sequence, as a
classmethod will of course allow us to have.  Maybe I'm missing some
recent Python enhancements, but I thought that, if a method is fully usable
as an instancemethod, then when called on the type it's an unbound method
and will ONLY support being called with an instance of the type as the 1st 
arg.

Hmmm... maybe one COULD make a custom descriptor that does support
both usages... and maybe it IS worth making the .sorted (or whatever name)
entry a case of exactly such a subtle custom descriptor...


Alex




More information about the Python-Dev mailing list