9 Oct 2016 9 Oct '16
On 8 October 2016 at 20:01, Serhiy Storchaka firstname.lastname@example.org 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.
As Raymond suggests, if order actually matters for a given use case, then use collections.OrderedDict unconditionally without worrying about the behaviour of the default dict implementation.
In addition to reducing code churn and improving cross-version and cross-implementation compatibility, doing that also lets the *reader* of the code know that the key iteration order matters.
-- Nick Coghlan | email@example.com | Brisbane, Australia