How about RETURN_NONE vs LOAD_CONST 0 (None); RETURN_VALUE ?
Bengt Richter
bokr at oz.net
Wed Dec 11 23:12:27 EST 2002
The boilerplate always returns None, so why not minimize the boilerplate
to one byte code? And maybe consider optimizing it away when it's easy,
e.g.,
>>> def foo():
... return 'why more?'
...
>>> dis.dis(foo)
0 LOAD_CONST 1 ('why more?')
3 RETURN_VALUE
4 LOAD_CONST 0 (None)
7 RETURN_VALUE
E.g., when would it be unsafe to eliminate it if the last statement
in the function is a return at indent level 1 ?
I guess it's a nit, but today I was doing some dis.dis and something
exceeded my nit-picking reflex threshold ;-)
Regards,
Bengt Richter
More information about the Python-list
mailing list