Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GH-132554: "Virtual" iterators #132555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7476442
FOR_ITER now pushes NULL as well as the iterator. Preparation for vir…
markshannon Apr 10, 2025
38a429f
use tagged ints for indexes. Work in progress
markshannon Apr 11, 2025
2caf56f
Remove debug code
markshannon Apr 15, 2025
588943a
Regenerate files
markshannon Apr 15, 2025
aa62e39
Tidy up list of non-escaping functions
markshannon Apr 16, 2025
88562ec
Fix up list iteration for FT build
markshannon Apr 16, 2025
025049d
Fix tier 2 FT build
markshannon Apr 16, 2025
35e389d
Remove debugging code
markshannon Apr 30, 2025
e8f4ce6
Merge branch 'main' into virtual-iterators
markshannon Apr 30, 2025
ed89950
Rename function
markshannon Apr 30, 2025
ec8d797
Restrict specialization in free-threaded build
markshannon Apr 30, 2025
cad1946
Merge branch 'main' into virtual-iterators
markshannon Apr 30, 2025
428735b
Add news
markshannon Apr 30, 2025
4c83848
handle tagged ints when doing type checks
markshannon Apr 30, 2025
f43ccc3
Fix long check
markshannon Apr 30, 2025
3fd46c3
Attempt to make _PyForIter_NextWithIndex thread safe.
markshannon Apr 30, 2025
433282f
Add review comment
markshannon Apr 30, 2025
e915a05
Simplify list indexing code
markshannon May 8, 2025
69a328d
Merge branch 'main' into virtual-iterators
markshannon May 8, 2025
6d1b93e
GET_ITER may leave the iterable on the stack
markshannon May 8, 2025
37ca285
Fix test_dis
markshannon May 8, 2025
f3b9074
Merge branch 'main' into virtual-iterators
markshannon May 19, 2025
0efab59
Merge branch 'main' into virtual-iterators
markshannon May 20, 2025
a0d814b
Merge branch 'main' into virtual-iterators
markshannon May 22, 2025
5cd55c4
Merge branch 'main' into virtual-iterators
markshannon May 22, 2025
867bd10
Merge branch 'main' into virtual-iterators
markshannon May 22, 2025
d9dc597
Clarify assert
markshannon May 27, 2025
d60ef23
Checked for tagged ints
markshannon May 27, 2025
9a9d20d
Address review comments
markshannon May 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use tagged ints for indexes. Work in progress
  • Loading branch information
markshannon committed Apr 29, 2025
commit 38a429f679839cb2e548a198c708064e9793ba82
2 changes: 2 additions & 0 deletions 2 Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ PyAPI_FUNC(_PyStackRef) _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyS
extern int _PyRunRemoteDebugger(PyThreadState *tstate);
#endif

_PyStackRef _PyForIter_NextWithIndex(PyObject *seq, _PyStackRef index);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion 2 Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ extern void _Py_Specialize_CompareOp(_PyStackRef lhs, _PyStackRef rhs,
_Py_CODEUNIT *instr, int oparg);
extern void _Py_Specialize_UnpackSequence(_PyStackRef seq, _Py_CODEUNIT *instr,
int oparg);
extern void _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg);
extern void _Py_Specialize_ForIter(_PyStackRef iter, _PyStackRef null_or_index, _Py_CODEUNIT *instr, int oparg);
extern void _Py_Specialize_Send(_PyStackRef receiver, _Py_CODEUNIT *instr);
extern void _Py_Specialize_ToBool(_PyStackRef value, _Py_CODEUNIT *instr);
extern void _Py_Specialize_ContainsOp(_PyStackRef value, _Py_CODEUNIT *instr);
Expand Down
2 changes: 1 addition & 1 deletion 2 Include/internal/pycore_opcode_metadata.h

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

18 changes: 17 additions & 1 deletion 18 Include/internal/pycore_stackref.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ extern intptr_t PyStackRef_UntagInt(_PyStackRef ref);

extern _PyStackRef PyStackRef_TagInt(intptr_t i);

extern _PyStackRef PyStackRef_IncrementTaggedInt(_PyStackRef ref);

markshannon marked this conversation as resolved.
Show resolved Hide resolved
extern bool
PyStackRef_IsNullOrInt(_PyStackRef ref);

Expand Down Expand Up @@ -262,6 +264,14 @@ PyStackRef_UntagInt(_PyStackRef i)
}


static inline _PyStackRef
PyStackRef_IncrementTaggedInt(_PyStackRef ref)
{
assert(ref.bits != (uintptr_t)-1); // Overflow
return (_PyStackRef){ .bits = ref.bits + 4 };
}


#ifdef Py_GIL_DISABLED

#define Py_TAG_DEFERRED (1)
Expand Down Expand Up @@ -686,7 +696,13 @@ PyStackRef_XCLOSE(_PyStackRef ref)

#endif // !defined(Py_GIL_DISABLED) && defined(Py_STACKREF_DEBUG)

#define PyStackRef_TYPE(stackref) Py_TYPE(PyStackRef_AsPyObjectBorrow(stackref))
static inline PyTypeObject *
PyStackRef_TYPE(_PyStackRef stackref) {
if (PyStackRef_IsTaggedInt(stackref)) {
return &PyLong_Type;
}
return Py_TYPE(PyStackRef_AsPyObjectBorrow(stackref));
}

// Converts a PyStackRef back to a PyObject *, converting the
// stackref to a new reference.
Expand Down
7 changes: 1 addition & 6 deletions 7 Include/internal/pycore_uop_ids.h

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

2 changes: 1 addition & 1 deletion 2 Include/internal/pycore_uop_metadata.h

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

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.