py/map: Convert map implementation to preserve insertion order (WIP, RFC) - #6173
Open
dpgeorge wants to merge 1 commit into
Open
py/map: Convert map implementation to preserve insertion order (WIP, RFC)#6173dpgeorge wants to merge 1 commit into
dpgeorge wants to merge 1 commit into
Conversation
TODO: - make it optional at compile-time - make OrderedDict use this new implementation - implement more efficient deletion - profile performance and memory use Signed-off-by: Damien George <damien@micropython.org>
Contributor
|
It's a much smaller/cleaner changeset than I'd expected. Once the existing OrderedDict implementation is removed I'd expect an overall flash saving. |
Contributor
|
Hi, another student and I wanted to create a pull request for dictionary union. Would it make sense for us to contribute to this pull request (e.g. addressing the TODOs) to have it eventually merged with master? Am I correct in assuming that there would be no point in creating a pull request for dictionary union without map ordering, or should we create the pull request anyways and have the discussion there (using sorted() inside the test to obviate to ordering issue for now)? |
tannewt
added a commit
to tannewt/circuitpython
that referenced
this pull request
Mar 21, 2022
…n-main Translations update from Hosted Weblate
kbsriram
added a commit
to kbsriram/circuitpython
that referenced
this pull request
Jul 15, 2023
Fixes adafruit#8173 It looks like a small fix, and mostly independent of upstream plans around micropython#6173 I also filed an issue upstream micropython#12011
dhalbert
pushed a commit
to dhalbert/circuitpython
that referenced
this pull request
Jul 23, 2023
Fixes adafruit#8173 It looks like a small fix, and mostly independent of upstream plans around micropython#6173 I also filed an issue upstream micropython#12011
This was referenced Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes the map implementation to make maps preserve insertion order, ie dicts are ordered by default. At this stage it's just for discussion, there's not (yet) any intention of merging it. See #6170 for additional discussion on this topic.
It uses a similar algorithm to PyPy/CPython. RAM overhead compared to the existing (non-order preserving) implementation is +12.5% for dicts with <255 elements, and +25% for dicts with <65535 elements. The code change is surprisingly simple.
TODO: