return statement in functions

Skip Montanaro skip at pobox.com
Tue Dec 23 19:49:05 EST 2003


    Carl> It seems that Python inserts the implicit "return None" even if
    Carl> you do return a value.

Yes, that's true.  A fairly straightforward basic block analysis can
eliminate the trailing LOAD_CONST None/RETURN_VALUE pair, but all you'd be
doing is reducing the size of the bytecode, not eliminating instructions
which would otherwise be executed.  Dead code elimination in other parts of
the bytecode is more interesting because it might lead an optimizer to
consider other possible optimizations.

Skip





More information about the Python-list mailing list