[Python-Dev] Check dict implementation details

Raymond Hettinger raymond.hettinger at gmail.com
Sat Oct 8 14:57:55 EDT 2016


> On Oct 8, 2016, at 3:01 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> 
> Since dict is ordered in CPython 3.6, it can be used instead of OrderedDict in some places (e.g. for implementing simple limited caches). But since this is implementation detail, it can't be used in the stdlib unconditionally. Needed a way to check whether dict is ordered.

I think this is premature and shouldn't be done.  Instead, everyone (including us) should follow Guido's directive that for now, the right way to provide an ordered dictionary is to use collections.OrderedDict.

In the future, we may reimplement collections.OrderedDict() in terms of the new compact dict and everything that uses OrderedDict will benefit from the change.  But for now, I think you should avoid wholesale rewrites of everything in the standard library that uses OrderedDict.

It seems to me that "needed a way to check whether dict is ordered" is just an end-run around Guido's decision.  Also, from a maintenance standpoint, we don't really want two code paths.  It is better to just let the new dict implementation play itself out.   There is no reason to rush to change lots of code that is currently working just fine.


Raymond


More information about the Python-Dev mailing list