Skip to content

perf: defer pretty import in console.py to Console.print()#4

Closed
KRRT7 wants to merge 1 commit intomasterfrom
perf/defer-pretty-console
Closed

perf: defer pretty import in console.py to Console.print()#4
KRRT7 wants to merge 1 commit intomasterfrom
perf/defer-pretty-console

Conversation

@KRRT7
Copy link
Copy Markdown
Owner

@KRRT7 KRRT7 commented Apr 9, 2026

Summary

Move from .pretty import Pretty, is_expandable from module level to inside _collect_renderables() (called by print()).

rich.pretty pulls in dataclasses, reprlib, array, and tries import attr — none of which are needed until something is actually printed.

Testing

952 passed on CPython 3.9–3.14 and PyPy 3.10.

Move `from .pretty import Pretty, is_expandable` from module level
to inside the `_collect_renderables()` method (called by `print()`).

rich.pretty pulls in dataclasses, reprlib, array, and tries `import
attr` — none of which are needed until something is actually printed.
@KRRT7
Copy link
Copy Markdown
Owner Author

KRRT7 commented Apr 9, 2026

Superseded by the consolidated stacked PRs #12 + #13.

@KRRT7 KRRT7 closed this Apr 9, 2026
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.

1 participant