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

Projects
None yet
4 participants
@takluyver
Member

takluyver commented Dec 21, 2017

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)

This comment has been minimized.

@njsmith

njsmith Dec 21, 2017

Contributor

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))
)

This comment has been minimized.

@takluyver

takluyver Dec 21, 2017

Member

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.

This comment has been minimized.

@njsmith

njsmith Dec 21, 2017

Contributor

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.

This comment has been minimized.

@tacaswell

tacaswell Dec 21, 2017

Contributor

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

This comment has been minimized.

@takluyver

takluyver Dec 21, 2017

Member

OK, I've set it to 3.6.

@takluyver takluyver changed the title from Don't sort dicts for display in Python >= 3.7 to Don't sort dicts for display in Python >= 3.6 Dec 22, 2017

@Carreau Carreau merged commit fee7d92 into ipython:master Dec 30, 2017

4 checks passed

codecov/patch 100% of diff hit (target 0%)
Details
codecov/project Absolute coverage decreased by -<.01% but relative coverage increased by +32.72% compared to 38e0033
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

meeseeksdev bot pushed a commit that referenced this pull request 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