python查看一条语句的执行效率和字节码
作者:互联网
>>> from timeit import timeit
>>> timeit("a = {'a': 1, 'b': 2}")
0.424...
>>> timeit("a = dict(a = 1, b = 2)")
0.889...
>>> import dis
>>> dis.dis("{ }")
0 <123> 32032
>>> dis.dis("dict()")
0 LOAD_CONST 25449 (25449)
3 LOAD_GLOBAL 10536 (10536)
>>>
标签:语句,...,timeit,字节,python,LOAD,dict,25449,dis 来源: https://blog.csdn.net/weixin_43270713/article/details/121081920