-
-
Notifications
You must be signed in to change notification settings - Fork 33k
bpo-31861: Provide aiter and anext builtins #23847
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
Changes from 36 commits
44b2a60
142523b
3ebce05
2f8df99
ad12116
ce35092
f9dc183
086bb79
29ef712
331e80e
95879d8
5b64589
6e145db
2fd4be6
430dd59
4266e65
ecbedc7
5fa3812
0f9c814
8160c82
fa8b12a
a2242d9
3ce5675
0038cde
06019ea
0cc00f2
8b8a689
894600d
e687d88
259af97
97d06e5
dd7c02d
2fbdd5b
009118c
71fede3
4a51ace
108e4a3
042f596
6ee8824
6f50ef8
ef40fb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,11 +324,21 @@ PyAPI_FUNC(PyObject *) PyObject_Format(PyObject *obj, | |
returns itself. */ | ||
PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *); | ||
|
||
/* Takes an AsyncIterable object and returns an AsyncIterator for it. | ||
This is typically a new iterator but if the argument is an AsyncIterator, | ||
this returns itself. */ | ||
PyAPI_FUNC(PyObject *) PyObject_GetAiter(PyObject *); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind adding this function -- while somewhat trivial, it's something that projects like Cython (and potentially our own modules like |
||
|
||
/* Returns non-zero if the object 'obj' provides iterator protocols, and 0 otherwise. | ||
|
||
This function always succeeds. */ | ||
PyAPI_FUNC(int) PyIter_Check(PyObject *); | ||
|
||
/* Returns non-zero if the object 'obj' provides AsyncIterator protocols, and 0 otherwise. | ||
|
||
This function always succeeds. */ | ||
PyAPI_FUNC(int) PyAiter_Check(PyObject *); | ||
|
||
/* Takes an iterator object and calls its tp_iternext slot, | ||
returning the next value. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ extern "C" { | |
|
||
PyAPI_DATA(PyTypeObject) PySeqIter_Type; | ||
PyAPI_DATA(PyTypeObject) PyCallIter_Type; | ||
PyAPI_DATA(PyTypeObject) PyAsyncCallAwaitable_Type; | ||
|
||
PyAPI_DATA(PyTypeObject) PyAnextAwaitable_Type; | ||
|
||
#define PySeqIter_Check(op) Py_IS_TYPE(op, &PySeqIter_Type) | ||
|
||
|
@@ -16,6 +18,7 @@ PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *); | |
#define PyCallIter_Check(op) Py_IS_TYPE(op, &PyCallIter_Type) | ||
|
||
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); | ||
PyAPI_FUNC(PyObject *) PyAnextAwaitable_New(PyObject *, PyObject *); | ||
|
||
#ifdef __cplusplus | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Add builtins.aiter and builtins.anext. | ||
Patch by Joshua Bronson (@jab), Daniel Pope (@lordmauve), and Justin Wang (@justin39). |
Uh oh!
There was an error while loading. Please reload this page.