gh-154675: pprint use lazy imports - #156803
Closed
edvilme wants to merge 3 commits into
Closed
Conversation
Use lazy imports instead of inline imports in pprint
johnslavik
reviewed
Sep 2, 2026
Comment on lines
+42
to
+44
| lazy from dataclasses import is_dataclass | ||
| lazy from dataclasses import fields as dataclass_fields | ||
| lazy import re |
Member
There was a problem hiding this comment.
Consider _is_dataclass, _dataclass_fields, _re as aliases instead, akin to the imports above.
Member
|
Do you have any benchmarks for various use cases? |
Member
I think this has zero impact on performance. The imports were always lazy, just inside the functions. |
Member
|
Oh right sorry, I don't know how I missed that. I think we can close this, it's just a refactor, and IMO churn. IIRC the PEP had a section that noted this will not be done? |
Member
|
I think so. The linked issue is about improving import times, but this PR does |
Member
|
There are no expensive modules that |
Member
|
Yes, I'm sorry but I'm closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use lazy imports instead of inline imports in pprint
CC @johnslavik