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

INADA Naoki songofacandy at gmail.com
Fri Dec 15 05:30:47 EST 2017


> That's interesting information - I wasn't aware of the different
> performance goals.

FYI, performance characteristic of my POC implementation of
OrderedDict based on dict order are:

* 50% less memory usage
* 15% faster creation
* 100% (2x) faster iteration
* 20% slower move_to_end
* 40% slower comparison

(copied from https://bugs.python.org/issue31265#msg301942 )

Comparison is very unoptimized at the moment and I believe it can be
more faster.
On the other hand, I'm not sure about I can optimize move_to_end() more.

If OrderdDict is recommended to be used for just keeping insertion order,
I feel 1/2 memory usage and 2x faster iteration are more important than
20% slower move_to_end().

But if either "dict keeps insertion order" or "dict keeps insertion order until
deletion" is language spec, there is no reason to use energy and time for
discussion of OrderedDict implementation.

Regards,

INADA Naoki  <songofacandy at gmail.com>


More information about the Python-Dev mailing list