[Python-ideas] Sorted lists

Nathaniel Smith njs at pobox.com
Sun Apr 7 23:26:24 EDT 2019

On Sun, Apr 7, 2019 at 7:37 PM Steven D'Aprano <steve at pearwood.info> wrote:
> There are quite a few important algorithms which require lists to be
> sorted. For example, the bisect module, and for statistics median and
> other quantiles.

But this flag doesn't affect those modules, right? 'bisect' already
requires the user to ensure that the list is sorted appropriately, and
this bit:

> The flag doesn't guarantee that the list is sorted the way you want
> (e.g. biggest to smallest, by some key, etc) only that it has been
> sorted. Its up to the user to ensure they sort it the right way:

...seems to mean that the 'statistics' module can't use this flag either.

It doesn't seem very likely to me that the savings from this flag
could outweigh the extra overhead it introduces, just because list
operations are *so* common in Python. If you want to push this
forward, the thing I'd most like to see is some kind of measurements
to demonstrate that average programs will benefit.


Nathaniel J. Smith -- https://vorpus.org

More information about the Python-ideas mailing list