Skip to content

Use lazy modules to reduce import time on 3.15+ - #5377

Open
harshil21 wants to merge 3 commits into
py315from
lazy-imports-v2
Open

harshil21 wants to merge 3 commits into
py315from
lazy-imports-v2

Conversation

@harshil21

Copy link
Copy Markdown
Member

Pass 2 of making lazy imports a reality on 3.15+ (Pass 1: #5231).

Seems like AI was able to reduce the import time which I couldn't quite do on my first pass on this a few months ago:

Import Before After
telegram 126.8 ms 26.3 ms
telegram.ext 142.8 ms 26.4 ms

Also made it add a pre-commit hook for maintaining the __lazy_imports__: It adds missing entries, removes stale ones, sorts and deduplicates both lists.

@harshil21 harshil21 added the 🔌 enhancement pr description: enhancement label Oct 11, 2026
@harshil21
harshil21 added this pull request to stack #5378 October 11, 2026 04:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔌 enhancement pr description: enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant