[Python-Dev] Guarantee ordered dict literals in v3.7?

Paul Moore p.f.moore at gmail.com
Fri Dec 15 03:52:29 EST 2017


On 15 December 2017 at 05:28, Raymond Hettinger
<raymond.hettinger at gmail.com> wrote:
> In contrast, I gave collections.OrderedDict a different design (later coded in C by Eric Snow).  The primary goal was to have efficient maintenance of order even for severe workloads such at that imposed by the lru_cache which frequently alters order without touching the underlying dict.   Intentionally, the OrderedDict has a design that prioritizes ordering capabilities at the expense of additional memory overhead and a constant factor worse insertion time.

That's interesting information - I wasn't aware of the different
performance goals. I'd suggest adding a discussion of these goals to
the OrderedDict documentation. Now that dictionaries preserve order
(whether or not we make that language guaranteed or an implementation
detail) having clear information on the intended performance
trade-offs of an OrderedDict would help people understand why they
might choose one over the other.

Paul


More information about the Python-Dev mailing list