Skip to content

gh-128559: Remove typing import from asyncio.timeouts #128560

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 6, 2025

Conversation

mikeshardmind
Copy link
Contributor

@mikeshardmind mikeshardmind commented Jan 6, 2025

This removes the runtime import of the typing module from asyncio.timeouts, decreasing startup time.

I'm not sure if this needs a news entry or more in-depth discussion, or if backports are appropriate here.

@bedevere-app
Copy link

bedevere-app bot commented Jan 6, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

News is needed, yeah. Something like "improved import time of asyncio.timeouts by %amount" should do.

FWIW, I'm not sure we want to keep type annotations here at all. The standard library isn't type-checked, and none of the other asyncio code uses type hints. If it's problematic because of startup times, then that's a convincing argument to remove them from the file entirely.

@mikeshardmind
Copy link
Contributor Author

mikeshardmind commented Jan 6, 2025

This won't be reliably measured as a %, this is a flat amount that varies based on whether or not typing.py is currently cached by the operating system, an the % would then vary also based on how many of the other imports an application has, and how many of them are in the os cache, I'll leave out the quantitative claim, but for context even with a warm cache , I've not seen typing ever end up below 45ms with -X importtime, so keeping this out of runtime imports makes a noticeable difference with lambdas.

I can remove the type hints entirely if that's preferred, and I'll go ahead with a news entry in a moment

…fxcDM.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Copy link
Contributor

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks, this change looks good to me. Hard to sell that this is a bugfix, so not planning on backporting

@hauntsaninja hauntsaninja merged commit 7363476 into python:main Jan 6, 2025
42 checks passed
@mikeshardmind mikeshardmind deleted the gh-128559-typing-removal branch January 6, 2025 23:48
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants