A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2016-October/146602.html below:

[Python-Dev] Check dict implementation details

[Python-Dev] Check dict implementation details [Python-Dev] Check dict implementation detailsNick Coghlan ncoghlan at gmail.com
Sat Oct 8 23:14:42 EDT 2016
On 8 October 2016 at 20:01, 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.

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.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4