gh-100239: expose sq_repeat helpers for BINARY_OP_EXTEND (#148791)

This commit is contained in:
Neko Asakura 2026-05-08 19:12:20 +08:00 committed by GitHub
parent 52a05e8da7
commit d2d24e46d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 46 additions and 74 deletions

View file

@ -8,7 +8,7 @@
#endif
#include "Python.h"
#include "pycore_bytesobject.h" // _PyBytes_Repeat
#include "pycore_bytesobject.h" // _PyBytes_RepeatBuffer
#include "pycore_call.h" // _PyObject_CallMethod()
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
#include "pycore_floatobject.h" // _PY_FLOAT_BIG_ENDIAN
@ -1147,7 +1147,7 @@ array_repeat(PyObject *op, Py_ssize_t n)
const Py_ssize_t oldbytes = array_length * a->ob_descr->itemsize;
const Py_ssize_t newbytes = oldbytes * n;
_PyBytes_Repeat(np->ob_item, newbytes, a->ob_item, oldbytes);
_PyBytes_RepeatBuffer(np->ob_item, newbytes, a->ob_item, oldbytes);
return (PyObject *)np;
}
@ -1304,7 +1304,7 @@ array_inplace_repeat(PyObject *op, Py_ssize_t n)
if (array_resize(self, n * array_size) == -1)
return NULL;
_PyBytes_Repeat(self->ob_item, n*size, self->ob_item, size);
_PyBytes_RepeatBuffer(self->ob_item, n*size, self->ob_item, size);
}
return Py_NewRef(self);
}