mirror of
https://github.com/python/cpython.git
synced 2026-01-06 07:22:09 +00:00
gh-103763: Implement PEP 695 (#103764)
This implements PEP 695, Type Parameter Syntax. It adds support for: - Generic functions (def func[T](): ...) - Generic classes (class X[T](): ...) - Type aliases (type X = ...) - New scoping when the new syntax is used within a class body - Compiler and interpreter changes to support the new syntax and scoping rules Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Eric Traut <eric@traut.com> Co-authored-by: Larry Hastings <larry@hastings.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
fdafdc235e
commit
24d8b88420
56 changed files with 11405 additions and 5469 deletions
|
|
@ -161,8 +161,12 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
|
|||
return 1;
|
||||
case DELETE_GLOBAL:
|
||||
return 0;
|
||||
case LOAD_NAME:
|
||||
case LOAD_LOCALS:
|
||||
return 0;
|
||||
case LOAD_NAME:
|
||||
return 0+1;
|
||||
case LOAD_FROM_DICT_OR_GLOBALS:
|
||||
return 1;
|
||||
case LOAD_GLOBAL:
|
||||
return 0;
|
||||
case LOAD_GLOBAL_MODULE:
|
||||
|
|
@ -175,8 +179,8 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
|
|||
return 0;
|
||||
case DELETE_DEREF:
|
||||
return 0;
|
||||
case LOAD_CLASSDEREF:
|
||||
return 0;
|
||||
case LOAD_FROM_DICT_OR_DEREF:
|
||||
return 1;
|
||||
case LOAD_DEREF:
|
||||
return 0;
|
||||
case STORE_DEREF:
|
||||
|
|
@ -551,7 +555,11 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
|
|||
return 0;
|
||||
case DELETE_GLOBAL:
|
||||
return 0;
|
||||
case LOAD_LOCALS:
|
||||
return 1;
|
||||
case LOAD_NAME:
|
||||
return 1+1;
|
||||
case LOAD_FROM_DICT_OR_GLOBALS:
|
||||
return 1;
|
||||
case LOAD_GLOBAL:
|
||||
return ((oparg & 1) ? 1 : 0) + 1;
|
||||
|
|
@ -565,7 +573,7 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
|
|||
return 0;
|
||||
case DELETE_DEREF:
|
||||
return 0;
|
||||
case LOAD_CLASSDEREF:
|
||||
case LOAD_FROM_DICT_OR_DEREF:
|
||||
return 1;
|
||||
case LOAD_DEREF:
|
||||
return 1;
|
||||
|
|
@ -869,14 +877,16 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = {
|
|||
[DELETE_ATTR] = { true, INSTR_FMT_IB },
|
||||
[STORE_GLOBAL] = { true, INSTR_FMT_IB },
|
||||
[DELETE_GLOBAL] = { true, INSTR_FMT_IB },
|
||||
[LOAD_LOCALS] = { true, INSTR_FMT_IB },
|
||||
[LOAD_NAME] = { true, INSTR_FMT_IB },
|
||||
[LOAD_FROM_DICT_OR_GLOBALS] = { true, INSTR_FMT_IB },
|
||||
[LOAD_GLOBAL] = { true, INSTR_FMT_IBC000 },
|
||||
[LOAD_GLOBAL_MODULE] = { true, INSTR_FMT_IBC000 },
|
||||
[LOAD_GLOBAL_BUILTIN] = { true, INSTR_FMT_IBC000 },
|
||||
[DELETE_FAST] = { true, INSTR_FMT_IB },
|
||||
[MAKE_CELL] = { true, INSTR_FMT_IB },
|
||||
[DELETE_DEREF] = { true, INSTR_FMT_IB },
|
||||
[LOAD_CLASSDEREF] = { true, INSTR_FMT_IB },
|
||||
[LOAD_FROM_DICT_OR_DEREF] = { true, INSTR_FMT_IB },
|
||||
[LOAD_DEREF] = { true, INSTR_FMT_IB },
|
||||
[STORE_DEREF] = { true, INSTR_FMT_IB },
|
||||
[COPY_FREE_VARS] = { true, INSTR_FMT_IB },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue