GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-154675: pprint use lazy imports by edvilme · Pull Request #156803 · python/cpython

Conversation

@edvilme

@edvilme edvilme commented Sep 1, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Use lazy imports instead of inline imports in pprint

CC @johnslavik

  • Issue: Improve import time of various stdlib modules #154675

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@edvilme
pythongh-154675: pprint use lazy imports
928cb08
Use lazy imports instead of inline imports in pprint
@bedevere-app bedevere-app Bot mentioned this pull request Sep 1, 2026
Improve import time of various stdlib modules #154675
Open
@bedevere-app bedevere-app Bot added the awaiting review label Sep 1, 2026
@blurb-it
📜🤖 Added by blurb_it.
82d7d1f
johnslavik
johnslavik reviewed Sep 2, 2026
View reviewed changes
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

@johnslavik johnslavik Sep 2, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@edvilme edvilme Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks, fixed in e055683

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@StanFromIreland

StanFromIreland commented Sep 2, 2026

Copy link
Copy Markdown
Member

Do you have any benchmarks for various use cases?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@johnslavik

johnslavik commented Sep 2, 2026

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

StanFromIreland commented 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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@edvilme
Use private imports
e055683
@edvilme
edvilme requested a review from johnslavik September 2, 2026 16:40
@johnslavik

johnslavik commented Sep 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@johnslavik

johnslavik commented Sep 2, 2026

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

StanFromIreland commented Sep 2, 2026

Copy link
Copy Markdown
Member

Yes, I'm sorry but I'm closing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StanFromIreland StanFromIreland closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@johnslavik johnslavik Awaiting requested review from johnslavik

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

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

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@edvilme @StanFromIreland @johnslavik
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.