homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Demur Rumed, serhiy.storchaka
Date 2016年05月27日.20:44:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464381862.41.0.0958175392432.issue27095@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016年05月27日 20:44:22serhiy.storchakasetrecipients: + serhiy.storchaka, Demur Rumed
2016年05月27日 20:44:22serhiy.storchakasetmessageid: <1464381862.41.0.0958175392432.issue27095@psf.upfronthosting.co.za>
2016年05月27日 20:44:22serhiy.storchakalinkissue27095 messages
2016年05月27日 20:44:21serhiy.storchakacreate

AltStyle によって変換されたページ (->オリジナル) /