300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > python 代码段的标志_Python代码类型标志

python 代码段的标志_Python代码类型标志

时间:2021-12-21 08:38:16

相关推荐

python 代码段的标志_Python代码类型标志

^{bq}$

来自PILER_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)。在

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。