04.12.17 01:06, Chris Barker пише:
So: has this already been brought up and rejected?

https://bugs.python.org/issue20632

Am I imagining the performance benefits?

This will add an additional overhead. This will be even slower than passing the key function, since you will need to look up the __key__ method in every item. And there will be an overhead even in the case when the __key__ method is not defined.

Is sorting-related functionally too special-case to deserve a protocol?

Yes, it is too special-case. I don't see any advantages in comparison with defining the __lt__ method. It will be rather confusing if different methods of sorting produce inconsistent order. If the first item of the sorted list is not the smallest item of the list.

But the idea of the class decorator looks more sane to me.

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to