|
1 | 1 | Implement :pep:`695`, adding syntactic support for generic classes, generic |
2 | 2 | functions, and type aliases. |
3 | 3 |
|
4 | | -This includes the following changes: |
| 4 | +A new ``type X = ...`` syntax is added for type aliases, which resolves at |
| 5 | +runtime to an instance of the new class ``typing.TypeAliasType``. |
| 6 | +The value is lazily evaluated and is accessible through the ``.__value__`` |
| 7 | +attribute. This is implemented as a new AST node ``ast.TypeAlias``. |
5 | 8 |
|
6 | | -- A new ``type X = ...`` syntax for type aliases, which resolves at |
7 | | - runtime to an instance of the new class ``typing.TypeAliasType``. |
8 | | - This is implemented as a new AST node ``ast.TypeAlias``. |
9 | | -- New syntax (``class X[T]: ...``, ``def func[T](): ...``) for defining |
10 | | - generic functions and classes. This is implemented as a new |
11 | | - ``typeparams`` attribute on the AST nodes for classes and functions. |
12 | | - This node holds instances of the new AST classes ``ast.TypeVar``, |
13 | | - ``ast.ParamSpec``, and ``ast.TypeVarTuple``. |
14 | | -- ``typing.TypeVar``, ``typing.ParamSpec``, ``typing.ParamSpecArgs``, |
15 | | - ``typing.ParamSpecKwargs``, ``typing.TypeVarTuple``, and |
16 | | - ``typing.Generic`` are now implemented in C rather than Python. |
17 | | -- New bytecode instructions ``LOAD_LOCALS`` and ``LOAD_CLASS_OR_GLOBAL`` |
18 | | - to support correct resolution of names in class namespaces. |
| 9 | +New syntax (``class X[T]: ...``, ``def func[T](): ...``) is added for defining |
| 10 | +generic functions and classes. This is implemented as a new |
| 11 | +``typeparams`` attribute on the AST nodes for classes and functions. |
| 12 | +This node holds instances of the new AST classes ``ast.TypeVar``, |
| 13 | +``ast.ParamSpec``, and ``ast.TypeVarTuple``. |
| 14 | + |
| 15 | +``typing.TypeVar``, ``typing.ParamSpec``, ``typing.ParamSpecArgs``, |
| 16 | +``typing.ParamSpecKwargs``, ``typing.TypeVarTuple``, and |
| 17 | +``typing.Generic`` are now implemented in C rather than Python. |
| 18 | + |
| 19 | +There are new bytecode instructions ``LOAD_LOCALS`` and ``LOAD_CLASS_OR_GLOBAL`` |
| 20 | +to support correct resolution of names in class namespaces. |
19 | 21 |
|
20 | 22 | Patch by Eric Traut, Larry Hastings, and Jelle Zijlstra. |
0 commit comments