mirror of
https://github.com/python/cpython.git
synced 2025-07-18 16:55:20 +00:00
GH-91719: Make MSVC generate somewhat faster switch code (#91718)
Apparently a switch on an 8-bit quantity where all cases are present generates a more efficient jump (doing only one indexed memory load instead of two). So we make opcode and use_tracing uint8_t, and generate a macro full of extra `case NNN:` lines for all unused opcodes. See https://github.com/faster-cpython/ideas/issues/321#issuecomment-1103263673
This commit is contained in:
parent
d44815cabc
commit
f8dc6186d1
4 changed files with 90 additions and 3 deletions
|
@ -129,6 +129,13 @@ def main(opcode_py, outfile='Include/opcode.h'):
|
|||
fobj.write("};\n")
|
||||
fobj.write("#endif\n")
|
||||
|
||||
fobj.write("\n")
|
||||
fobj.write("#define EXTRA_CASES \\\n")
|
||||
for i, flag in enumerate(used):
|
||||
if not flag:
|
||||
fobj.write(f" case {i}: \\\n")
|
||||
fobj.write(" ;\n")
|
||||
|
||||
fobj.write(footer)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue