Idle bytecode query on apparently unreachable returns

Neal Norwitz nnorwitz at gmail.com
Sun Oct 9 22:01:25 EDT 2005


Tom Anderson wrote:
> Evening all,
>
> Here's a brief chat with the interpretator:

[snip]

> What puzzles me, though, are bytecodes 17, 39 and 42 - surely these aren't
> reachable? Does the compiler just throw in a default 'return None'
> epilogue, with routes there from every code path, even when it's not
> needed? If so, why?

I think the last RETURN_VALUE (None) isn't thrown in unless there is
some sort of conditional the precedes it as in this example.

As to why:  it's easier and no one has done anything about fixing it.
If you (or anyone else) are interested, the code is in
Python/compile.c.  Search for the optimize_code() function.

n




More information about the Python-list mailing list