[issue24075] list.sort() should do quick exit if len(list) <= 1
Sergey B Kirpichev
report at bugs.python.org
Wed Apr 29 22:25:30 CEST 2015
Sergey B Kirpichev added the comment:
On Wed, Apr 29, 2015 at 06:51:21PM +0000, Paul Moore wrote:
> But that's a sort without a key.
Why it does matter? It have quick exit. For same reasons - Python could...
> In Perl you do a key sort via:
That's just your implementation. But we could add here a
quick exit as well.
> The fact of the matter is that what Python does is documented behaviour
No. Unless you absolutely sure - all readers think that "sorting
process" starts even for trivial lists. No reasons to believe in that
nonsense - as you could see from sorting implementations in other languages.
> benefit (small) isn't worth the cost of making a change (which would
> only be in Python 3.5 and later anyway
It's easy for users (i.e. me) to backport this feature (i.e. make wrapper for
sorted()). Benefit is small, I admit, but why not remove unnecessary
restrictions from the language? I hope, I did my best to explain why.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24075>
_______________________________________
More information about the Python-bugs-list
mailing list