[issue28685] Optimizing list.sort() by performing safety checks in advance

STINNER Victor report at bugs.python.org
Mon Nov 14 12:32:50 EST 2016


STINNER Victor added the comment:

Maybe we should investigate more optimizations on specialized lists.

PyPy uses a more compact structure for lists of integers for example. Something like compact strings, PEP 393, of Python 3.3, but for lists.

http://doc.pypy.org/en/latest/interpreter-optimizations.html#list-optimizations

But we are limited by the C API, so we cannot change deeply the C structure without breaking backward compatibility.


> # (difference is within std dev)

You can use perf timeit --compare-to to check if the result is significant or not, and it displays you the "N.NNx faster" or "N.NNx slower" if it's significant.

About benchmarks, I also would like to see a benchmark on the bad case, when specialization is not used. And not only on an empty list :-) For example, sort 1000 objects which implement compare operators and/or a sort function.

----------
nosy: +haypo

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28685>
_______________________________________


More information about the Python-bugs-list mailing list