return statement in functions

Skip Montanaro skip at pobox.com
Wed Dec 24 01:49:05 CET 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