diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2021-10-09 15:51:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-09 15:51:30 (GMT) |
commit | b4903afd4debbbd71dc49a2c8fefa74a3b6c6832 (patch) | |
tree | d5bc6105eb25f47ed2b72f446c66ac4f6d12cc62 /Objects/tupleobject.c | |
parent | ec04db74e24a5f5da441bcabbe259157b4938b9b (diff) | |
download | cpython-b4903afd4debbbd71dc49a2c8fefa74a3b6c6832.zip cpython-b4903afd4debbbd71dc49a2c8fefa74a3b6c6832.tar.gz cpython-b4903afd4debbbd71dc49a2c8fefa74a3b6c6832.tar.bz2 |
bpo-45256: Remove the usage of the C stack in Python to Python calls (GH-28488)
Ths commit inlines calls to Python functions in the eval loop and steals all the arguments in the call from the caller for
performance.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r-- | Objects/tupleobject.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index e64b93b..018e738 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -484,6 +484,26 @@ _PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) return (PyObject *)tuple; } +PyObject * +_PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n) +{ + if (n == 0) { + return tuple_get_empty(); + } + + PyTupleObject *tuple = tuple_alloc(n); + if (tuple == NULL) { + return NULL; + } + PyObject **dst = tuple->ob_item; + for (Py_ssize_t i = 0; i < n; i++) { + PyObject *item = src[i]; + dst[i] = item; + } + _PyObject_GC_TRACK(tuple); + return (PyObject *)tuple; +} + static PyObject * tupleslice(PyTupleObject *a, Py_ssize_t ilow, Py_ssize_t ihigh) |