Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3a6f48d
Add FOR_ITER specialization for virtual iterators. Specialize GET_ITER.
markshannon Mar 17, 2026
74b5289
Document new tp_iteritem function slot.
markshannon Apr 1, 2026
4dd6992
Simplify list_iteritem
markshannon Apr 1, 2026
4376246
Make it clearer to MSVC that variable doesn't escape
markshannon Apr 2, 2026
5a81e54
Return a small struct in tp_iteritem to support MSVC tailcalling
markshannon Apr 2, 2026
b927de4
Fix editing slip
markshannon Apr 2, 2026
044cce2
Put limited RESUME at start of genexpr for free-threading. Fix up exc…
markshannon Apr 7, 2026
4ba6ecd
Merge branch 'main' into specialize-iteration-with-jit
markshannon Apr 7, 2026
b08dce2
Merge branch 'main' into specialize-iteration-with-jit
markshannon Apr 8, 2026
830068c
Fix test_dis
markshannon Apr 8, 2026
931084a
Merge branch 'main' into specialize-iteration-with-jit
markshannon Apr 9, 2026
87215d5
Merge branch 'main' into specialize-iteration-with-jit
markshannon Apr 9, 2026
73b9b87
Fix magic number
markshannon Apr 9, 2026
fdef628
Address review comments
markshannon Apr 13, 2026
b8baca5
Merge branch 'main' into specialize-iteration-with-jit
markshannon Apr 13, 2026
b3dc340
Make struct private
markshannon Apr 13, 2026
1c269b6
Try to keep sphinx happy
markshannon Apr 14, 2026
09ecaef
Declare tp_iteritem and iteritemfunc private by adding _ prefix to names
markshannon Apr 14, 2026
92a3a97
Merge branch 'main' into specialize-iteration-with-jit
markshannon Apr 15, 2026
a55ac63
Address code review: Remove struct tag
markshannon Apr 15, 2026
6406871
Merge branch 'main' into specialize-iteration-with-jit
markshannon Apr 16, 2026
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ struct _typeobject {
destructor tp_finalize;
vectorcallfunc tp_vectorcall;

/* Below here all fields are internal to the VM */

/* bitset of which type-watchers care about this type */
unsigned char tp_watched;

Expand All @@ -239,6 +241,7 @@ struct _typeobject {
* Otherwise, limited to MAX_VERSIONS_PER_CLASS (defined elsewhere).
*/
uint16_t tp_versions_used;
_Py_iteritemfunc _tp_iteritem; /* Virtual iterator next function */
};

#define _Py_ATTR_CACHE_UNUSED (30000) // (see tp_versions_used)
Expand Down
7 changes: 7 additions & 0 deletions Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ typedef struct {

#define INLINE_CACHE_ENTRIES_FOR_ITER CACHE_ENTRIES(_PyForIterCache)

typedef struct {
_Py_BackoffCounter counter;
} _PyGetIterCache;

#define INLINE_CACHE_ENTRIES_GET_ITER CACHE_ENTRIES(_PyGetIterCache)

typedef struct {
_Py_BackoffCounter counter;
} _PySendCache;
Expand Down Expand Up @@ -324,6 +330,7 @@ PyAPI_FUNC(void) _Py_Specialize_ContainsOp(_PyStackRef value, _Py_CODEUNIT *inst
PyAPI_FUNC(void) _Py_GatherStats_GetIter(_PyStackRef iterable);
PyAPI_FUNC(void) _Py_Specialize_CallFunctionEx(_PyStackRef func_st, _Py_CODEUNIT *instr);
PyAPI_FUNC(void) _Py_Specialize_Resume(_Py_CODEUNIT *instr, PyThreadState *tstate, _PyInterpreterFrame *frame);
PyAPI_FUNC(void) _Py_Specialize_GetIter(_PyStackRef iterable, _Py_CODEUNIT *instr);

// Utility functions for reading/writing 32/64-bit values in the inline caches.
// Great care should be taken to ensure that these functions remain correct and
Expand Down
3 changes: 2 additions & 1 deletion Include/internal/pycore_magic_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ Known values:
Python 3.15a8 3662 (Add counter to RESUME)
Python 3.15a8 3663 (Merge GET_ITER and GET_YIELD_FROM_ITER. Modify SEND to make it a bit more like FOR_ITER)
Python 3.15a8 3664 (Fix __qualname__ for __annotate__ functions)
Python 3.15a8 3665 (Add FOR_ITER_VIRTUAL and GET_ITER specializations)


Python 3.16 will start with 3700
Expand All @@ -308,7 +309,7 @@ PC/launcher.c must also be updated.

*/

#define PYC_MAGIC_NUMBER 3664
#define PYC_MAGIC_NUMBER 3665
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
(little-endian) and then appending b'\r\n'. */
#define PYC_MAGIC_NUMBER_TOKEN \
Expand Down
35 changes: 27 additions & 8 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Include/internal/pycore_opcode_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ extern "C" {
#define RESUME_AFTER_YIELD 1
#define RESUME_AFTER_YIELD_FROM 2
#define RESUME_AFTER_AWAIT 3
#define RESUME_AT_GEN_EXPR_START 4

#define RESUME_OPARG_LOCATION_MASK 0x3
#define RESUME_OPARG_DEPTH1_MASK 0x4
#define RESUME_OPARG_LOCATION_MASK 0x7
#define RESUME_OPARG_DEPTH1_MASK 0x8

#define GET_ITER_YIELD_FROM 1
#define GET_ITER_YIELD_FROM_NO_CHECK 2
Expand Down
Loading
Loading