GH-143732: SEND specialization (GH-148963) · sthagen/python-cpython@70bd1c2 · GitHub
Skip to content

Commit 70bd1c2

Browse files
authored
pythonGH-143732: SEND specialization (pythonGH-148963)
* SEND specialization. Adds 2 new specialized instructions: * SEND_VIRTUAL: for sends to virtual iterators e.g lists and tuples * SEND_ASYNC_GEN: for sends to async generators Tweak FOR_ITER_VIRTUAL so that SEND_VIRTUAL and FOR_ITER_VIRTUAL use equivalent guards
1 parent ffb543d commit 70bd1c2

29 files changed

Lines changed: 2689 additions & 1575 deletions

Include/cpython/object.h

Lines changed: 5 additions & 1 deletion

Include/internal/pycore_abstract.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ PyAPI_FUNC(int) _Py_convert_optional_to_non_negative_ssize_t(PyObject *, void *)
6060
// Export for 'math' shared extension.
6161
PyAPI_FUNC(PyObject*) _PyNumber_Index(PyObject *o);
6262

63+
typedef struct {
64+
PyObject *object;
65+
PySendResult kind;
66+
} PySendResultPair;
67+
68+
// Same as PyIter_Send but returns a struct for MSVC tailcall support
69+
PyAPI_FUNC(PySendResultPair) _PyIter_Send(PyObject *iter, PyObject *arg);
70+
6371
#ifdef __cplusplus
6472
}
6573
#endif

Include/internal/pycore_genobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ extern PyTypeObject _PyCoroWrapper_Type;
4040
extern PyTypeObject _PyAsyncGenWrappedValue_Type;
4141
extern PyTypeObject _PyAsyncGenAThrow_Type;
4242

43+
PyAPI_FUNC(PySendResult) _PyAsyncGenASend_Send(PyObject *iter, PyObject *arg, PyObject **result);
44+
4345
#ifdef __cplusplus
4446
}
4547
#endif

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 1 deletion

Include/internal/pycore_opcode_metadata.h

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

0 commit comments

Comments
 (0)