Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Add steal versions
  • Loading branch information
sergey-miryanov committed Oct 13, 2025
commit 5f81e49b8c390cff238202dd21925ad8b951adc2
2 changes: 2 additions & 0 deletions Include/tupleobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);

PyAPI_FUNC(PyObject *) PyTuple_MakeSingle(PyObject *one);
PyAPI_FUNC(PyObject *) PyTuple_MakeSingleSteal(PyObject *one);
PyAPI_FUNC(PyObject *) PyTuple_MakePair(PyObject *one, PyObject *two);
PyAPI_FUNC(PyObject *) PyTuple_MakePairSteal(PyObject *one, PyObject *two);
PyAPI_FUNC(PyObject *) PyTuple_MakeTriplet(PyObject *one, PyObject *two, PyObject *three);


Expand Down
34 changes: 34 additions & 0 deletions Objects/tupleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,22 @@ PyTuple_MakeSingle(PyObject *one)
return (PyObject *) op;
}


PyObject *
PyTuple_MakeSingleSteal(PyObject *one)
{
assert (one != NULL);

PyTupleObject *op = tuple_alloc(1);
if (op == NULL) {
Py_DECREF(one);
return NULL;
}
op->ob_item[0] = one;
_PyObject_GC_TRACK(op);
return (PyObject *) op;
}

PyObject *
PyTuple_MakePair(PyObject *one, PyObject *two)
{
Expand All @@ -1212,6 +1228,24 @@ PyTuple_MakePair(PyObject *one, PyObject *two)
return (PyObject *) op;
}

PyObject *
PyTuple_MakePairSteal(PyObject *one, PyObject *two)
{
assert (one != NULL);
assert (two != NULL);

PyTupleObject *op = tuple_alloc(2);
if (op == NULL) {
Py_DECREF(one);
Py_DECREF(two);
return NULL;
}
op->ob_item[0] = one;
op->ob_item[1] = two;
_PyObject_GC_TRACK(op);
return (PyObject *) op;
}

PyObject *
PyTuple_MakeTriplet(PyObject *one, PyObject *two, PyObject *three)
{
Expand Down