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

Don't sort dicts for display in Python >= 3.6 #10958

Merged
merged 2 commits into from Dec 30, 2017

Conversation

takluyver
Copy link
Member

Closes gh-10110

@takluyver takluyver added this to the 5.6 milestone Dec 21, 2017
@@ -95,6 +95,7 @@ def _repr_pretty_(self, p, cycle):


MAX_SEQ_LENGTH = 1000
DICT_IS_ORDERED = sys.version_info >= (3, 7)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe:

DICT_IS_ORDERED = (
    sys.version_info >= (3, 7)
    or platform.python_implementation() == "PyPy"
    or (platform.python_implementation() == "CPython" and sys.version_info >= (3, 6))
)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm inclined to use 3.7, because that's when Python dicts are defined as being ordered, rather than it being up to the implementation.

If we want to push it faster, I'd rather say 3.6 than start checking which implementation it is. But following the language definition feels like the better thing to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to suggest making it sys.version_info >= (3, 6), and then guessed that you would give the pedantically correct response that technically there could someday be a 3.6 valid implementation that doesn't have ordered dicts, so I switched to the exact pedantically accurate check you see above :-).

I'm not sure how it helps end-users to order their dicts differently on 3.6 versus 3.7, given that in practice the actual interpreter behavior is identical. Most users don't understand the complex metaphysical question of how the exact same behavior is different depending on whether it's nominally accidental or nominally intentional. OTOH we do have multiple reports from people that the sorting on 3.6 is causing them pain right now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I lobby for not sorting on 3.6+ on the practicality over purity platform.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I've set it to 3.6.

@takluyver takluyver changed the title Don't sort dicts for display in Python >= 3.7 Don't sort dicts for display in Python >= 3.6 Dec 22, 2017
@Carreau Carreau merged commit fee7d92 into ipython:master Dec 30, 2017
Carreau added a commit that referenced this pull request Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants