| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -575,6 +575,8 @@ iterations of the loop. | |||
| 575 | 575 | ||
| 576 | 576 | Pops TOS and yields it from a :term:`generator`. | |
| 577 | 577 | ||
| 578 | + .. versionchanged:: 3.11 | ||
| 579 | + oparg set to be the stack depth, for efficient handling on frames. | ||
| 578 | 580 | ||
| 579 | 581 | .. opcode:: YIELD_FROM | |
| 580 | 582 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -405,6 +405,7 @@ def _write_atomic(path, data, mode=0o666): | |||
| 405 | 405 | # Python 3.11a7 3494 (New location info table) | |
| 406 | 406 | ||
| 407 | 407 | # Python 3.12a1 3500 (Remove PRECALL opcode) | |
| 408 | + # Python 3.12a1 3501 (YIELD_VALUE oparg == stack_depth) | ||
| 408 | 409 | ||
| 409 | 410 | # Python 3.13 will start with 3550 | |
| 410 | 411 | ||
@@ -418,7 +419,7 @@ def _write_atomic(path, data, mode=0o666): | |||
| 418 | 419 | # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array | |
| 419 | 420 | # in PC/launcher.c must also be updated. | |
| 420 | 421 | ||
| 421 | - MAGIC_NUMBER = (3500).to_bytes(2, 'little') + b'\r\n' | ||
| 422 | + MAGIC_NUMBER = (3501).to_bytes(2, 'little') + b'\r\n' | ||
| 422 | 423 | ||
| 423 | 424 | _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c | |
| 424 | 425 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,7 +98,7 @@ def jabs_op(name, op): | |||
| 98 | 98 | def_op('RETURN_VALUE', 83) | |
| 99 | 99 | def_op('IMPORT_STAR', 84) | |
| 100 | 100 | def_op('SETUP_ANNOTATIONS', 85) | |
| 101 | - def_op('YIELD_VALUE', 86) | ||
| 101 | + | ||
| 102 | 102 | def_op('ASYNC_GEN_WRAP', 87) | |
| 103 | 103 | def_op('PREP_RERAISE_STAR', 88) | |
| 104 | 104 | def_op('POP_EXCEPT', 89) | |
@@ -174,7 +174,7 @@ def jabs_op(name, op): | |||
| 174 | 174 | def_op('LOAD_CLASSDEREF', 148) | |
| 175 | 175 | hasfree.append(148) | |
| 176 | 176 | def_op('COPY_FREE_VARS', 149) | |
| 177 | - | ||
| 177 | + def_op('YIELD_VALUE', 150) | ||
| 178 | 178 | def_op('RESUME', 151) | |
| 179 | 179 | def_op('MATCH_CLASS', 152) | |
| 180 | 180 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + The operand of the ``YIELD_VALUE`` instruction is set to the stack depth. | ||
| 2 | + This is done to help frame handling on ``yield`` and may assist debuggers. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2698,6 +2698,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int | |||
| 2698 | 2698 | } | |
| 2699 | 2699 | ||
| 2700 | 2700 | TARGET(YIELD_VALUE) { | |
| 2701 | + assert(oparg == STACK_LEVEL()); | ||
| 2701 | 2702 | assert(frame->is_entry); | |
| 2702 | 2703 | PyObject *retval = POP(); | |
| 2703 | 2704 | _PyFrame_GetGenerator(frame)->gi_frame_state = FRAME_SUSPENDED; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1962,7 +1962,7 @@ compiler_add_yield_from(struct compiler *c, int await) | |||
| 1962 | 1962 | compiler_use_next_block(c, start); | |
| 1963 | 1963 | ADDOP_JUMP(c, SEND, exit); | |
| 1964 | 1964 | compiler_use_next_block(c, resume); | |
| 1965 | - ADDOP(c, YIELD_VALUE); | ||
| 1965 | + ADDOP_I(c, YIELD_VALUE, 0); | ||
| 1966 | 1966 | ADDOP_I(c, RESUME, await ? 3 : 2); | |
| 1967 | 1967 | ADDOP_JUMP(c, JUMP_NO_INTERRUPT, start); | |
| 1968 | 1968 | compiler_use_next_block(c, exit); | |
@@ -4193,7 +4193,7 @@ addop_yield(struct compiler *c) { | |||
| 4193 | 4193 | if (c->u->u_ste->ste_generator && c->u->u_ste->ste_coroutine) { | |
| 4194 | 4194 | ADDOP(c, ASYNC_GEN_WRAP); | |
| 4195 | 4195 | } | |
| 4196 | - ADDOP(c, YIELD_VALUE); | ||
| 4196 | + ADDOP_I(c, YIELD_VALUE, 0); | ||
| 4197 | 4197 | ADDOP_I(c, RESUME, 1); | |
| 4198 | 4198 | return 1; | |
| 4199 | 4199 | } | |
@@ -7152,6 +7152,9 @@ stackdepth(struct compiler *c, basicblock *entry) | |||
| 7152 | 7152 | next = NULL; | |
| 7153 | 7153 | break; | |
| 7154 | 7154 | } | |
| 7155 | + if (instr->i_opcode == YIELD_VALUE) { | ||
| 7156 | + instr->i_oparg = depth; | ||
| 7157 | + } | ||
| 7155 | 7158 | } | |
| 7156 | 7159 | if (next != NULL) { | |
| 7157 | 7160 | assert(b->b_nofallthrough == 0); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments