[issue35369] List sorting makes duplicate comparisons

David Wyde report at bugs.python.org
Sat Dec 1 03:01:14 EST 2018


David Wyde <david.wyde at gmail.com> added the comment:

Thanks for the speedy and helpful response.

Keeping complexity down is fair. The wasted if-checks on subsequent iterations are certainly a negative trade-off. I saw that binarysort() is only called in one place, but I understand wanting to keep it generic.

I think that slow comparison functions, especially when repeatedly sorting short lists, are the main use case.

I don't know if that's common in performance-critical code. I've heard of using human choices for comparisons, when fewer decisions could provide a notable speedup. The patched code seems a bit slower in some situations, but is faster in others.

Do you think it's worth posting to python-ideas to see what people's use cases are?

----------
Added file: https://bugs.python.org/file47964/sort-fix-2.diff

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35369>
_______________________________________


More information about the Python-bugs-list mailing list