mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
GH-77273: Better bytecodes for f-strings (GH-6132)
This commit is contained in:
parent
307bceaa65
commit
1d857da7f0
15 changed files with 525 additions and 485 deletions
|
@ -402,8 +402,12 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
|
|||
return 0;
|
||||
case BUILD_SLICE:
|
||||
return ((oparg == 3) ? 1 : 0) + 2;
|
||||
case FORMAT_VALUE:
|
||||
return (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0) + 1;
|
||||
case CONVERT_VALUE:
|
||||
return 1;
|
||||
case FORMAT_SIMPLE:
|
||||
return 1;
|
||||
case FORMAT_WITH_SPEC:
|
||||
return 2;
|
||||
case COPY:
|
||||
return (oparg-1) + 1;
|
||||
case BINARY_OP:
|
||||
|
@ -820,7 +824,11 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
|
|||
return 0;
|
||||
case BUILD_SLICE:
|
||||
return 1;
|
||||
case FORMAT_VALUE:
|
||||
case CONVERT_VALUE:
|
||||
return 1;
|
||||
case FORMAT_SIMPLE:
|
||||
return 1;
|
||||
case FORMAT_WITH_SPEC:
|
||||
return 1;
|
||||
case COPY:
|
||||
return (oparg-1) + 2;
|
||||
|
@ -1064,7 +1072,9 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[512] = {
|
|||
[SET_FUNCTION_ATTRIBUTE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
|
||||
[RETURN_GENERATOR] = { true, INSTR_FMT_IX, 0 },
|
||||
[BUILD_SLICE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
|
||||
[FORMAT_VALUE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
|
||||
[CONVERT_VALUE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
|
||||
[FORMAT_SIMPLE] = { true, INSTR_FMT_IX, 0 },
|
||||
[FORMAT_WITH_SPEC] = { true, INSTR_FMT_IX, 0 },
|
||||
[COPY] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
|
||||
[BINARY_OP] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG },
|
||||
[SWAP] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue