##// END OF EJS Templates
Don't sort dicts for display in Python >= 3.7...
Thomas Kluyver -
Show More
@@ -95,6 +95,7 b" __all__ = ['pretty', 'pprint', 'PrettyPrinter', 'RepresentationPrinter',"
95 95
96 96
97 97 MAX_SEQ_LENGTH = 1000
98 DICT_IS_ORDERED = sys.version_info >= (3, 7)
98 99 _re_pattern_type = type(re.compile(''))
99 100
100 101 def _safe_getattr(obj, attr, default=None):
@@ -613,7 +614,9 b' def _dict_pprinter_factory(start, end, basetype=None):'
613 614 p.begin_group(step, start)
614 615 keys = obj.keys()
615 616 # if dict isn't large enough to be truncated, sort keys before displaying
616 if not (p.max_seq_length and len(obj) >= p.max_seq_length):
617 # From Python 3.7, dicts preserve order by definition, so we don't sort.
618 if not DICT_IS_ORDERED \
619 and not (p.max_seq_length and len(obj) >= p.max_seq_length):
617 620 keys = _sorted_for_pprint(keys)
618 621 for idx, key in p._enumerate(keys):
619 622 if idx:
General Comments 0
You need to be logged in to leave comments. Login now