PEP 511
* Change code_transformer() API. The method now takes a code object as input and must return a code object. * Be more explicit: code_transformer() and ast_transformer() are methods taking a self parameter.
This commit is contained in:
parent
d45c401bb2
commit
3910522c12
24
pep-0511.txt
24
pep-0511.txt
|
@ -263,32 +263,32 @@ to join code transformer names to build the optimizer tag.
|
|||
``PyParser_ASTFromStringObject()``.
|
||||
|
||||
|
||||
code_transformer()
|
||||
------------------
|
||||
code_transformer() method
|
||||
-------------------------
|
||||
|
||||
Prototype::
|
||||
|
||||
def code_transformer(code, consts, names, lnotab, context):
|
||||
def code_transformer(self, code, context):
|
||||
...
|
||||
return (code, consts, names, lnotab)
|
||||
new_code = ...
|
||||
...
|
||||
return new_code
|
||||
|
||||
Parameters:
|
||||
|
||||
* *code*: the bytecode (``bytes``)
|
||||
* *consts*: a sequence of constants
|
||||
* *names*: tuple of variable names
|
||||
* *lnotab*: table mapping instruction offsets to line numbers
|
||||
(``bytes``)
|
||||
* *code*: code object
|
||||
|
||||
The method must return a code object.
|
||||
|
||||
The code transformer is run after the compilation to bytecode
|
||||
|
||||
|
||||
ast_transformer()
|
||||
------------------
|
||||
ast_transformer() method
|
||||
------------------------
|
||||
|
||||
Prototype::
|
||||
|
||||
def ast_transformer(tree, context):
|
||||
def ast_transformer(self, tree, context):
|
||||
...
|
||||
return tree
|
||||
|
||||
|
|
Loading…
Reference in New Issue