bpo-32949: Better bytecodes for "with" statement.#5112
Conversation
|
Please open an issue for the discussion. I was going to make different changes in with-related opcodes after merging #5006, but your approach may be better. Needed some microbenchmarks for comparing implementations. You can simplify and speed up the bytecode (get rid of |
Sorry, something went wrong.
…parate code for normal and exceptional paths.
445f25b to
e9f7689
Compare
March 11, 2018 19:24
|
@markshannon, are you aware that tests are failed with your current code? And merging with master will add failures in new tests. |
Sorry, something went wrong.
|
I've decided that generating new bytecodes for the |
Sorry, something went wrong.
This PR cleans up the interpreter by generating two different code paths for exiting a
withstatement. One for normal exits and another for the exceptional case.For this function:
The bytecode generated changes from:
to
Although this superficially appears worse, consider the non-exceptional path, after the
POP_BLOCKbytecode.before:
after:
we have replaced several complex and inefficient bytecodes with a few more simpler and faster bytecodes.
https://bugs.python.org/issue32949