@@ -92,6 +92,7 @@ This module currently contains the following:
92
92
- ` TypedDict ` (see [ PEP 589] ( https://peps.python.org/pep-0589/ ) )
93
93
- ` get_origin ` (` typing_extensions ` provides this function only in Python 3.7+)
94
94
- ` get_args ` (` typing_extensions ` provides this function only in Python 3.7+)
95
+ - ` SupportsIndex `
95
96
96
97
- In ` typing ` since Python 3.7
97
98
@@ -126,6 +127,17 @@ This module currently contains the following:
126
127
- ` NamedTuple ` (supports multiple inheritance with ` Generic ` since Python 3.11)
127
128
- ` TypeVar ` (see PEPs [ 695] ( https://peps.python.org/pep-0695/ ) and [ 696] ( https://peps.python.org/pep-0696/ ) )
128
129
130
+ The following runtime-checkable protocols have always been present in ` typing ` ,
131
+ but the ` isinstance() ` checks against the ` typing_extensions ` versions are much
132
+ faster on Python <3.12:
133
+
134
+ - ` SupportsInt `
135
+ - ` SupportsFloat `
136
+ - ` SupportsComplex `
137
+ - ` SupportsBytes `
138
+ - ` SupportsAbs `
139
+ - ` SupportsRound `
140
+
129
141
# Other Notes and Limitations
130
142
131
143
Certain objects were changed after they were added to ` typing ` , and
@@ -156,6 +168,16 @@ Certain objects were changed after they were added to `typing`, and
156
168
- ` TypeVar ` gains two additional parameters, ` default= ` and ` infer_variance= ` ,
157
169
in the draft PEPs [ 695] ( https://peps.python.org/pep-0695/ ) and [ 696] ( https://peps.python.org/pep-0696/ ) , which are being considered for inclusion
158
170
in Python 3.12.
171
+ - ` Protocol ` was added in Python 3.8, but several bugfixes have been made in
172
+ subsequent releases, as well as significant performance improvements to
173
+ runtime-checkable protocols in Python 3.12. ` typing_extensions ` backports the
174
+ 3.12+ version to Python 3.7+.
175
+ - ` SupportsInt ` , ` SupportsFloat ` , ` SupportsComplex ` , ` SupportsBytes ` ,
176
+ ` SupportsAbs ` and ` SupportsRound ` have always been present in the ` typing `
177
+ module. Meanwhile, ` SupportsIndex ` was added in Python 3.8. However,
178
+ ` isinstance() ` checks against all these protocols were sped up significantly
179
+ on Python 3.12. ` typing_extensions ` backports the faster versions to Python
180
+ 3.7+.
159
181
- ` Literal ` does not flatten or deduplicate parameters on Python <3.9.1, and a
160
182
caching bug was fixed in 3.10.1/3.9.8. The ` typing_extensions ` version
161
183
flattens and deduplicates parameters on all Python versions, and the caching
0 commit comments