GH-132554: "Virtual" iterators (GH-132555) · python/cpython@f6f4e8a · GitHub
Skip to content

Commit f6f4e8a

Browse files
authored
GH-132554: "Virtual" iterators (GH-132555)
* FOR_ITER now pushes either the iterator and NULL or leaves the iterable and pushes tagged zero * NEXT_ITER uses the tagged int as the index into the sequence or, if TOS is NULL, iterates as before.
1 parent 9300a59 commit f6f4e8a

25 files changed

Lines changed: 709 additions & 614 deletions

Include/internal/pycore_ceval.h

Lines changed: 2 additions & 0 deletions

Include/internal/pycore_code.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ extern void _Py_Specialize_CompareOp(_PyStackRef lhs, _PyStackRef rhs,
313313
_Py_CODEUNIT *instr, int oparg);
314314
extern void _Py_Specialize_UnpackSequence(_PyStackRef seq, _Py_CODEUNIT *instr,
315315
int oparg);
316-
extern void _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg);
316+
extern void _Py_Specialize_ForIter(_PyStackRef iter, _PyStackRef null_or_index, _Py_CODEUNIT *instr, int oparg);
317317
extern void _Py_Specialize_Send(_PyStackRef receiver, _Py_CODEUNIT *instr);
318318
extern void _Py_Specialize_ToBool(_PyStackRef value, _Py_CODEUNIT *instr);
319319
extern void _Py_Specialize_ContainsOp(_PyStackRef value, _Py_CODEUNIT *instr);

Include/internal/pycore_compile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ typedef enum {
9595
enum _PyCompile_FBlockType {
9696
COMPILE_FBLOCK_WHILE_LOOP,
9797
COMPILE_FBLOCK_FOR_LOOP,
98+
COMPILE_FBLOCK_ASYNC_FOR_LOOP,
9899
COMPILE_FBLOCK_TRY_EXCEPT,
99100
COMPILE_FBLOCK_FINALLY_TRY,
100101
COMPILE_FBLOCK_FINALLY_END,

Include/internal/pycore_magic_number.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ Known values:
279279
Python 3.14b1 3624 (Don't optimize LOAD_FAST when local is killed by DELETE_FAST)
280280
Python 3.15a0 3650 (Initial version)
281281
Python 3.15a1 3651 (Simplify LOAD_CONST)
282+
Python 3.15a1 3652 (Virtual iterators)
283+
282284
283285
Python 3.16 will start with 3700
284286
@@ -291,7 +293,7 @@ PC/launcher.c must also be updated.
291293
292294
*/
293295

294-
#define PYC_MAGIC_NUMBER 3651
296+
#define PYC_MAGIC_NUMBER 3652
295297
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
296298
(little-endian) and then appending b'\r\n'. */
297299
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_opcode_metadata.h

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_stackref.h

Lines changed: 40 additions & 34 deletions

Include/internal/pycore_uop_ids.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)