← 返回首页
gh-74690: Avoid a costly type check where possible in `_ProtocolMeta.__subclasscheck__` by AlexWaygood · Pull Request #112717 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

gh-74690: Avoid a costly type check where possible in _ProtocolMeta.__subclasscheck__#112717

Merged
AlexWaygood merged 3 commits into
python:mainfrom
AlexWaygood:protocolmeta-subclasscheck
Dec 4, 2023
Merged

gh-74690: Avoid a costly type check where possible in _ProtocolMeta.__subclasscheck__#112717
AlexWaygood merged 3 commits into
python:mainfrom
AlexWaygood:protocolmeta-subclasscheck

Conversation

AlexWaygood commented Dec 4, 2023
edited
Loading

Copy link
Copy Markdown
Member

This speeds up issubclass(int, typing.SupportsIndex) by around 6%.

The approach is to move the code around a bit so that we delegate the type-checking to type.__subclasscheck__ wherever possible; type.__subclasscheck__ can do it faster. We now only check from _ProtocolMeta.__subclasscheck__ whether other is an instance of type if we know we're about to raise an exception anyway, and we want the issubclass() arg 2 must be a type message to take priority over the other error message we could potentially give the user.

barneygale left a comment

Copy link
Copy Markdown
Contributor

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 Quality Hide comment

Looks good! Is it important that the "issubclass() arg 1 must be a class" error message takes precedence over the others? It's not obvious to me that it should, but I'm not very familiar with this code.

AlexWaygood commented Dec 4, 2023
edited
Loading

Copy link
Copy Markdown
Member Author

Thanks for the review! :D

Looks good! Is it important that the "issubclass() arg 1 must be a class" error message takes precedence over the others? It's not obvious to me that it should, but I'm not very familiar with this code.

Yeah, so to clarify, with the type checks, this is the behaviour we get with this PR branch:

Python 3.13.0a2+ (heads/main:9560e0d6d7, Dec 4 2023, 13:50:58) [MSC v.1932 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import typing as t >>> @t.runtime_checkable ... class Foo(t.Protocol): ... X = 1 ... >>> issubclass("not a class", Foo) Traceback (most recent call last): File "<stdin>", line 1, in <module> issubclass("not a class", Foo) ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "C:\Users\alexw\coding\fast-cpython\Lib\typing.py", line 1842, in __subclasscheck__ _type_check_subclasscheck_second_arg(other) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ File "C:\Users\alexw\coding\fast-cpython\Lib\typing.py", line 1796, in _type_check_subclasscheck_second_arg raise TypeError('issubclass() arg 1 must be a class') TypeError: issubclass() arg 1 must be a class

But without the type checks, we'd get this behaviour instead:

>>> import typing as t >>> @t.runtime_checkable ... class Foo(t.Protocol): ... X = 1 ... >>> issubclass("not a class", Foo) Traceback (most recent call last): File "<stdin>", line 1, in <module> issubclass("not a class", Foo) ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "C:\Users\alexw\coding\fast-cpython\Lib\typing.py", line 1847, in __subclasscheck__ raise TypeError( ...<2 lines>... ) TypeError: Protocols with non-method members don't support issubclass(). Non-method members: 'X'.

It wouldn't be the worst thing in the world if we had that error message instead. But the fact that Foo has non-method members is clearly not the most significant problem with this person's code! So I definitely prefer to prioritise the "issubclass() arg 1 must be a class" message, if possible :)

Copy link
Copy Markdown
Member Author

I added a docstring in 3c7eb19 -- does that make things a bit clearer? :)

Copy link
Copy Markdown
Contributor

It does indeed! Thank you.

AlexWaygood enabled auto-merge (squash) December 4, 2023 18:59
Comment thread Lib/typing.py Outdated Show resolved Hide resolved
AlexWaygood merged commit 2ed20d3 into python:main Dec 4, 2023
AlexWaygood deleted the protocolmeta-subclasscheck branch December 4, 2023 19:35
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Feb 26, 2024
Release 4.10.0 (February 24, 2024) This feature release adds support for PEP 728 (TypedDict with extra items) and PEP 742 (``TypeIs``). There are no changes since 4.10.0rc1. Release 4.10.0rc1 (February 17, 2024) - Add support for PEP 728, supporting the `closed` keyword argument and the special `__extra_items__` key for TypedDict. Patch by Zixuan James Li. - Add support for PEP 742, adding `typing_extensions.TypeIs`. Patch by Jelle Zijlstra. - Drop runtime error when a read-only `TypedDict` item overrides a mutable one. Type checkers should still flag this as an error. Patch by Jelle Zijlstra. - Speedup `issubclass()` checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717, by Alex Waygood). - Fix a regression in the implementation of protocols where `typing.Protocol` classes that were not marked as `@runtime_checkable` would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. Patch by Alex Waygood, backporting python/cpython#113401.
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 0a1b1a2eefa66ff5d8eb12085d3ecfed0eff7ac1) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 0a1b1a2eefa66ff5d8eb12085d3ecfed0eff7ac1) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 2fee4e85e88bea2ac7c42a1c93a3049258a47c45) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 2fee4e85e88bea2ac7c42a1c93a3049258a47c45) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 5b138eb2bf420f1dc81db76b2eb7d74fd88c0c29) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 5b138eb2bf420f1dc81db76b2eb7d74fd88c0c29) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 5b138eb2bf420f1dc81db76b2eb7d74fd88c0c29) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 955ab06da61db7393ad54a87e5f2536f0dae3cf2) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 955ab06da61db7393ad54a87e5f2536f0dae3cf2) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 955ab06da61db7393ad54a87e5f2536f0dae3cf2) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 955ab06da61db7393ad54a87e5f2536f0dae3cf2) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Feb 29, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Mar 1, 2024
Changelog: ============ -Add support for PEP 728, supporting the closed keyword argument and the special __extra_items__ key for TypedDict. -Add support for PEP 742, adding typing_extensions.TypeIs. -Drop runtime error when a read-only TypedDict item overrides a mutable one. Type checkers should still flag this as an error. -Speedup issubclass() checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717 -Fix a regression in the implementation of protocols where typing.Protocol classes that were not marked as @runtime_checkable would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. (From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
msk pushed a commit to msk/pkgsrc that referenced this pull request May 11, 2026
Release 4.10.0 (February 24, 2024) This feature release adds support for PEP 728 (TypedDict with extra items) and PEP 742 (``TypeIs``). There are no changes since 4.10.0rc1. Release 4.10.0rc1 (February 17, 2024) - Add support for PEP 728, supporting the `closed` keyword argument and the special `__extra_items__` key for TypedDict. Patch by Zixuan James Li. - Add support for PEP 742, adding `typing_extensions.TypeIs`. Patch by Jelle Zijlstra. - Drop runtime error when a read-only `TypedDict` item overrides a mutable one. Type checkers should still flag this as an error. Patch by Jelle Zijlstra. - Speedup `issubclass()` checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717, by Alex Waygood). - Fix a regression in the implementation of protocols where `typing.Protocol` classes that were not marked as `@runtime_checkable` would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. Patch by Alex Waygood, backporting python/cpython#113401.
jperkin pushed a commit to TritonDataCenter/pkgsrc that referenced this pull request May 14, 2026
Release 4.10.0 (February 24, 2024) This feature release adds support for PEP 728 (TypedDict with extra items) and PEP 742 (``TypeIs``). There are no changes since 4.10.0rc1. Release 4.10.0rc1 (February 17, 2024) - Add support for PEP 728, supporting the `closed` keyword argument and the special `__extra_items__` key for TypedDict. Patch by Zixuan James Li. - Add support for PEP 742, adding `typing_extensions.TypeIs`. Patch by Jelle Zijlstra. - Drop runtime error when a read-only `TypedDict` item overrides a mutable one. Type checkers should still flag this as an error. Patch by Jelle Zijlstra. - Speedup `issubclass()` checks against simple runtime-checkable protocols by around 6% (backporting python/cpython#112717, by Alex Waygood). - Fix a regression in the implementation of protocols where `typing.Protocol` classes that were not marked as `@runtime_checkable` would be unnecessarily introspected, potentially causing exceptions to be raised if the protocol had problematic members. Patch by Alex Waygood, backporting python/cpython#113401.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance or resource usage topic-typing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Footer

© 2026 GitHub, Inc.