Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch internal instances of collections.OrderedDict to regular dict #3030

Merged
merged 1 commit into from Jan 22, 2021

Conversation

neutrinoceros
Copy link
Member

PR Summary

…when the differences do not matter any more: starting from Python 3.6, normal dict objects preserve insertion order.
I was originally aiming at replacing all ordereddict by normal dict but I left every user-facing one untouched because comparison is still different between the two classes, so I don't mean to cause bugs downwards where OrderedDict is possibly still relevant.

…when the differences do not matter any more (starting from python 3.6, dict objects preserve insertion order)
@neutrinoceros neutrinoceros added the refactor improve readability, maintainability, modularity label Jan 21, 2021
@@ -69,7 +67,6 @@ def __init__(

if fields is None:
fields = []
fields = list(OrderedDict.fromkeys(fields))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not look obvious but the current implementation here is actually doing nothing, so I went with the option of preserving behaviour rather than intent. I think the original intent was to sort the keys, in which case it should be simply reimplemented as

fields = sorted(keys)

@jzuhone , do you remember this ? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine. I also think that someone came in here and did this later, because I don't recognize the code to be honest.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for your prompt answer

@@ -69,7 +67,6 @@ def __init__(

if fields is None:
fields = []
fields = list(OrderedDict.fromkeys(fields))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine. I also think that someone came in here and did this later, because I don't recognize the code to be honest.

@cphyc cphyc merged commit 6dd525c into yt-project:main Jan 22, 2021
@neutrinoceros neutrinoceros deleted the ordered_dict_no_more branch January 22, 2021 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor improve readability, maintainability, modularity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants