mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
bpo-47012: speed up iteration of bytes and bytearray (GH-31867)
This commit is contained in:
parent
894d0ea5af
commit
bd1cf6ecee
4 changed files with 13 additions and 9 deletions
|
@ -23,8 +23,9 @@ extern void _PyLong_FiniTypes(PyInterpreterState *interp);
|
|||
#define _PyLong_SMALL_INTS _Py_SINGLETON(small_ints)
|
||||
|
||||
// _PyLong_GetZero() and _PyLong_GetOne() must always be available
|
||||
#if _PY_NSMALLPOSINTS < 2
|
||||
# error "_PY_NSMALLPOSINTS must be greater than 1"
|
||||
// _PyLong_FromUnsignedChar must always be available
|
||||
#if _PY_NSMALLPOSINTS < 257
|
||||
# error "_PY_NSMALLPOSINTS must be greater than or equal to 257"
|
||||
#endif
|
||||
|
||||
// Return a borrowed reference to the zero singleton.
|
||||
|
@ -37,6 +38,11 @@ static inline PyObject* _PyLong_GetZero(void)
|
|||
static inline PyObject* _PyLong_GetOne(void)
|
||||
{ return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS+1]; }
|
||||
|
||||
static inline PyObject* _PyLong_FromUnsignedChar(unsigned char i)
|
||||
{
|
||||
return Py_NewRef((PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS+i]);
|
||||
}
|
||||
|
||||
PyObject *_PyLong_Add(PyLongObject *left, PyLongObject *right);
|
||||
PyObject *_PyLong_Multiply(PyLongObject *left, PyLongObject *right);
|
||||
PyObject *_PyLong_Subtract(PyLongObject *left, PyLongObject *right);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue