Skip to content

Supporting insertion-order preservation property of dicts (compat with Python 3.7+) #6170

@dpgeorge

Description

@dpgeorge

Python 3.7 made dicts ordered by default, see https://docs.python.org/3/whatsnew/3.7.html

Since it's part of the Python spec, and there are situations where this feature is useful, it makes sense to consider how MicroPython could support it. It may be that it's not realistic to have such a feature in MicroPython by default, maybe in the end it's just a build option for those who need it.

The problem is that implementing it efficiently (retaining O(1) lookup) requires more memory for the dict implementation than is currently used. The alternative is to make lookups O(N) which is proposed in #5323 (see that PR for further discussion).

Another alternative might be to just have ordered dicts only in certain places. There are currently requests for it in the following places:

Metadata

Metadata

Assignees

No one assigned

    Labels

    py-coreRelates to py/ directory in source

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions