Skip to content

Add sort_dicts parameter to reprlib.Repr (gh-155812) - #1

Open
SparshGarg999 wants to merge 2 commits into
mainfrom
feat-reprlib-sort-dicts-155812
Open

Add sort_dicts parameter to reprlib.Repr (gh-155812)#1
SparshGarg999 wants to merge 2 commits into
mainfrom
feat-reprlib-sort-dicts-155812

Conversation

@SparshGarg999

Copy link
Copy Markdown
Owner

Fixes pythongh-155812

Summary

reprlib.Repr currently sorts dictionary keys unconditionally. In applications where key insertion order represents structured precedence or semantic sequence, key sorting can obscure the intended structure.

This PR adds a sort_dicts: bool = True parameter to reprlib.Repr.__init__ (defaulting to True to preserve existing behavior) and updates dictionary representation logic to respect self.sort_dicts.

How was this tested?

  • Tested reprlib.Repr(sort_dicts=False) and reprlib.Repr(sort_dicts=True) formatting on dictionaries.

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.

Add sort_dicts parameter to reprlib.Repr

1 participant