^{bq}$
来自dis.COMPILER_FLAG_NAMES:1 OPTIMIZED
2 NEWLOCALS
4 VARARGS
8 VARKEYWORDS
16 NESTED
32 GENERATOR
64 NOFREE
128 COROUTINE
256 ITERABLE_COROUTINE
它来自python3,但是python2.7中可用的标志保持了Include/code.h中的相同值。它们只由Jython记录。在the function (the inner codetype) is 71
71 = 1 + 2 + 4 + 64:
^{pr2}$
示例(在Python 3中):>>> import dis
>>> def f(a, b, c, *args):
... print(a, b, c, args)
...
>>> dis.show_code(f)
Name: f
Filename:
Argument count: 3
Kw-only arguments: 0
Number of locals: 4
Stack size: 5
Flags: OPTIMIZED, NEWLOCALS, VARARGS, NOFREE
Constants:
0: None
Names:
0: print
Variable names:
0: a
1: b
2: c
3: argswhy the container is set to 64 as all it does is set functions up eg there is no variable arguments used?
据我所知,“容器”是一个模块(检查co_name)。NOFREE只是意味着没有freevars,cellvars那是(总是?)对于模块为真。在pypyco_flags上是0(the flags are the same there)。在