State in README that we backport the 3.12 version of `Protocol`, `runtime_checkable` and various runtime-checkable protocols (#143)
diff --git a/README.md b/README.md index d23dbd4..b7e6a7a 100644 --- a/README.md +++ b/README.md
@@ -92,6 +92,7 @@ - `TypedDict` (see [PEP 589](https://peps.python.org/pep-0589/)) - `get_origin` (`typing_extensions` provides this function only in Python 3.7+) - `get_args` (`typing_extensions` provides this function only in Python 3.7+) + - `SupportsIndex` - In `typing` since Python 3.7 @@ -126,6 +127,17 @@ - `NamedTuple` (supports multiple inheritance with `Generic` since Python 3.11) - `TypeVar` (see PEPs [695](https://peps.python.org/pep-0695/) and [696](https://peps.python.org/pep-0696/)) +The following runtime-checkable protocols have always been present in `typing`, +but the `isinstance()` checks against the `typing_extensions` versions are much +faster on Python <3.12: + + - `SupportsInt` + - `SupportsFloat` + - `SupportsComplex` + - `SupportsBytes` + - `SupportsAbs` + - `SupportsRound` + # Other Notes and Limitations Certain objects were changed after they were added to `typing`, and @@ -156,6 +168,16 @@ - `TypeVar` gains two additional parameters, `default=` and `infer_variance=`, 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 in Python 3.12. +- `Protocol` was added in Python 3.8, but several bugfixes have been made in + subsequent releases, as well as significant performance improvements to + runtime-checkable protocols in Python 3.12. `typing_extensions` backports the + 3.12+ version to Python 3.7+. +- `SupportsInt`, `SupportsFloat`, `SupportsComplex`, `SupportsBytes`, + `SupportsAbs` and `SupportsRound` have always been present in the `typing` + module. Meanwhile, `SupportsIndex` was added in Python 3.8. However, + `isinstance()` checks against all these protocols were sped up significantly + on Python 3.12. `typing_extensions` backports the faster versions to Python + 3.7+. - `Literal` does not flatten or deduplicate parameters on Python <3.9.1, and a caching bug was fixed in 3.10.1/3.9.8. The `typing_extensions` version flattens and deduplicates parameters on all Python versions, and the caching