[Python-ideas] Sorted lists

Paul Moore p.f.moore at gmail.com
Mon Apr 8 06:39:05 EDT 2019

On Mon, 8 Apr 2019 at 11:27, Steven D'Aprano <steve at pearwood.info> wrote:
> Fair enough, but does it help you feel a bit better about the feature if
> we called it a "sort hint", and emphasized that it should only be used
> in the same sort of APIs where you might allow the caller to pass
>     already_sorted=True
> to skip a redundant sort step?

Not really, because already_sorted=True is an explicit claim by the
user, whereas the (internally maintained) dunder attribute is the
interpreter maintaining a (not guaranteed reliable but pessimistic to
be as safe as possible) view on whether the data is sorted.

But I see elsewhere in the thread that you're now more inclined
towards an explicit already_sorted flag, so I won't labour the point.

More information about the Python-ideas mailing list