Skip to content

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

Merged
mergify[bot] merged 1 commit into
jd:mainfrom
ichard26:lazy
Mar 14, 2024
Merged

Lazy import asyncio.sleep as it's expensive#450
mergify[bot] merged 1 commit into
jd:mainfrom
ichard26:lazy

Conversation

@ichard26

@ichard26 ichard26 commented Mar 13, 2024

Copy link
Copy Markdown
Contributor

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.
@mergify

mergify Bot commented Mar 13, 2024

Copy link
Copy Markdown
Contributor

⚠️ No release notes detected. Please make sure to use reno to add a changelog entry.

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.

2 participants