Serhiy Storchaka added the comment: In general the patch LGTM, besides few minor comments.
But new implementation uses longer bytecode for annotations. Current code packs argument names in one constant tuple: $ ./python -m dis def f(x: int, y: str, z: float): pass 1 0 LOAD_NAME 0 (int) 2 LOAD_NAME 1 (str) 4 LOAD_NAME 2 (float) 6 LOAD_CONST 0 (('x', 'y', 'z')) 8 LOAD_CONST 1 (<code object f at 0xb6fc1640, file "<stdin>", line 1>) 10 LOAD_CONST 2 ('f') 12 EXTENDED_ARG 4 14 EXTENDED_ARG 1024 16 MAKE_FUNCTION 262144 18 STORE_NAME 3 (f) 20 LOAD_CONST 3 (None) 22 RETURN_VALUE New code uses LOAD_CONST for every name: $ ./python -m dis def f(x: int, y: str, z: float): pass 1 0 LOAD_CONST 0 ('x') 2 LOAD_NAME 0 (int) 4 LOAD_CONST 1 ('y') 6 LOAD_NAME 1 (str) 8 LOAD_CONST 2 ('z') 10 LOAD_NAME 2 (float) 12 BUILD_MAP 3 14 LOAD_CONST 3 (<code object f at 0xb7035a20, file "<stdin>", line 1>) 16 LOAD_CONST 4 ('f') 18 MAKE_FUNCTION 4 20 STORE_NAME 3 (f) 22 LOAD_CONST 5 (None) 24 RETURN_VALUE With new opcode that creates a dict from values and a tuple of keys (issue27140) new code would be only one instruction longer. ---------- stage: -> patch review _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27095> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com