The following function returns None :
In [5]: def f(): ...: pass
Therefore, I was not surprised by this output:
In [8]: dis.dis(f) 2 0 LOAD_CONST 0 (None) 3 RETURN_VALUE In [10]: f.__code__.co_consts Out[10]: (None,)
Ok, that makes sense. But now consider the following function:
In [11]: def g(): ....: return 1 In [12]: dis.dis(g) 2 0 LOAD_CONST 1 (1) 3 RETURN_VALUE In [13]: g.__code__.co_consts Out[13]: (None, 1)
g doesn't use None , so why is it in co_consts ?
usual me
source share