| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| :func:`isinstance` checks against :func:`runtime-checkable protocols | ||
| <typing.runtime_checkable>` now use :func:`inspect.getattr_static` rather | ||
| than :func:`hasattr` to lookup whether attributes exist. This means that | ||
| descriptors and :meth:`~object.__getattr__` methods are no longer | ||
| unexpectedly evaluated during ``isinstance()`` checks against | ||
| runtime-checkable protocols. However, it may also mean that some objects | ||
| which used to be considered instances of a runtime-checkable protocol may no | ||
| longer be considered instances of that protocol on Python 3.12+, and vice | ||
| versa. Most users are unlikely to be affected by this change. Patch by Alex | ||
| Waygood. |
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIs this really worth it? inspect is likely already imported by a lot of programs (e.g. anything that uses dataclasses or asyncio), so is it really so bad to import it here?
Relatedly, my intuition was that the @cache wouldn't help much because the import is already cached, but in fact the cache makes it 20x faster on my computer: I guess there's still a lot of overhead in going through the import system.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think it is worth it, yes:
I don't think this is a great argument. asyncio and dataclasses might import inspect now, but that doesn't mean that they'll necessarily continue to do so indefinitely. If somebody decides to try to improve import the import time of dataclasses by moving to a lazy import of inspect (for example), we'd be left looking pretty silly by making a decision on the basis that "dataclasses imports inspect, so it's okay for us to do it too". Besides, there's lots of code that doesn't make any use of dataclasses or asyncio.
Yes, I was also surprised at how much the @cache sped things up here :)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.