FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-154675: pprint use lazy imports by edvilme · Pull Request #156803 · python/cpython · GitHub

Repository navigation

gh-154675: pprint use lazy imports - #156803

Closed
edvilme wants to merge 3 commits into
python:mainfrom
edvilme:pprint-lazy-import
Closed

edvilme wants to merge 3 commits into
python:mainfrom
edvilme:pprint-lazy-import

Conversation

edvilme commented Sep 1, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Use lazy imports instead of inline imports in pprint

CC @johnslavik

Use lazy imports instead of inline imports in pprint
Comment thread Lib/pprint.py Outdated
Comment on lines +42 to +44
lazy from dataclasses import is_dataclass
lazy from dataclasses import fields as dataclass_fields
lazy import re

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Consider _is_dataclass, _dataclass_fields, _re as aliases instead, akin to the imports above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks, fixed in e055683

Copy link
Copy Markdown
Member

Do you have any benchmarks for various use cases?

Copy link
Copy Markdown
Member

Do you have any benchmarks for various use cases?

I think this has zero impact on performance. The imports were always lazy, just inside the functions.

StanFromIreland added the type-refactor Code refactoring (with no changes in behavior) label Sep 2, 2026

Copy link
Copy Markdown
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?

edvilme requested a review from johnslavik September 2, 2026 16:40

johnslavik commented Sep 2, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

I think so. The linked issue is about improving import times, but this PR does
not improve import time.

Copy link
Copy Markdown
Member

There are no expensive modules that pprint eagerly imports, so there's not much we can do.

StanFromIreland added the pending The issue will be closed if no feedback is provided label Sep 2, 2026

Copy link
Copy Markdown
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

Labels

awaiting review pending The issue will be closed if no feedback is provided type-refactor Code refactoring (with no changes in behavior)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL