Don't sort dicts for display in Python >= 3.6#10958
Conversation
|
|
||
|
|
||
| MAX_SEQ_LENGTH = 1000 | ||
| DICT_IS_ORDERED = sys.version_info >= (3, 7) |
There was a problem hiding this comment.
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))
)There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I lobby for not sorting on 3.6+ on the practicality over purity platform.
There was a problem hiding this comment.
OK, I've set it to 3.6.
Backport PR #10958 on branch 5.x
Closes gh-10110