Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy import asyncio.sleep as it's expensive #450

Merged
merged 1 commit into from
Mar 14, 2024
Merged

Conversation

ichard26
Copy link
Contributor

@ichard26 ichard26 commented Mar 13, 2024

On my system, importing tenacity (without tornado) takes 25ms, and asyncio is singlehandedly responsible for 14ms. Some users do not ever use AsyncRetrying (or asyncio in their project generally) and it would be a shame for them to incur a unnecessary import penalty.

Full disclaimer: I pursued this change primarily to reduce pip's startup time where asyncio was a nontrivial portion of the import timeline.

Import waterfall running import tenacity (without tornado installed). Note that time is scaled by 1000 so 1s == 1ms.

Feel free to reject this PR if you don't like this 馃檪

On my system, importing tenacity (_without tornado_) takes 35ms, and
asyncio is singlehandedly responsible for 15ms. Some users do not ever
use AsyncRetrying (or asyncio in their project generally) and it would
be a shame for them to incur a unnecessary import penalty.

Full disclaimer: I pursued this change primarily to reduce pip's startup
time where asyncio was a nontrivial portion of the import timeline.
Copy link
Contributor

mergify bot commented Mar 13, 2024

鈿狅笍 No release notes detected. Please make sure to use reno to add a changelog entry.

@jd jd added the no-changelog No changelog needed label Mar 14, 2024
@mergify mergify bot merged commit cb15300 into jd:main Mar 14, 2024
10 checks passed
@ichard26 ichard26 deleted the lazy branch March 14, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog No changelog needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants