Skip to content

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
Fix up list iteration for FT build
  • Loading branch information
markshannon committed Apr 29, 2025
commit 88562ec76b46e50b4202d89f99efdf331529082a
3 changes: 1 addition & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3202,8 +3202,7 @@ dummy_func(
EXIT_IF(Py_TYPE(iter_o) != &PyList_Type);
assert(PyStackRef_IsTaggedInt(null_or_index));
#ifdef Py_GIL_DISABLED
EXIT_IF(!_Py_IsOwnedByCurrentThread(iter_o) ||
!_PyObject_GC_IS_SHARED(iter_o));
EXIT_IF(!_Py_IsOwnedByCurrentThread(iter_o) && !_PyObject_GC_IS_SHARED(iter_o));
#endif
}

Expand Down
3 changes: 1 addition & 2 deletions Python/executor_cases.c.h

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

3 changes: 1 addition & 2 deletions Python/generated_cases.c.h

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

9 changes: 3 additions & 6 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2905,13 +2905,10 @@ _Py_Specialize_ForIter(_PyStackRef iter, _PyStackRef null_or_index, _Py_CODEUNIT
PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter);
PyTypeObject *tp = Py_TYPE(iter_o);
#ifdef Py_GIL_DISABLED
// Only specialize for uniquely referenced iterators, so that we know
// they're only referenced by this one thread. This is more limiting
// than we need (even `it = iter(mylist); for item in it:` won't get
// specialized) but we don't have a way to check whether we're the only
// _thread_ who has access to the object.
if (!_PyObject_IsUniquelyReferenced(iter_o))
// Only specialize for lists owned by this thread or shared
if (!_Py_IsOwnedByCurrentThread(iter_o) && !_PyObject_GC_IS_SHARED(iter_o)) {
goto failure;
}
#endif
if (PyStackRef_IsNull(null_or_index)) {
if (tp == &PyRangeIter_Type) {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy