Skip to content

Commit befeded

Browse files
committed
Add inplace binary operations for type int-int
1 parent 8e9d21c commit befeded

File tree

9 files changed

+2384
-1274
lines changed

9 files changed

+2384
-1274
lines changed

Include/internal/pycore_long.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ static inline PyObject* _PyLong_FromUnsignedChar(unsigned char i)
8282
return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS+i];
8383
}
8484

85+
// Return a reference to the cached small int singleton.
86+
// The caller must ensure -_PY_NSMALLNEGINTS <= value < _PY_NSMALLPOSINTS.
87+
static inline PyObject* _PyLong_GetSmallInt(Py_ssize_t value)
88+
{
89+
assert(-_PY_NSMALLNEGINTS <= value && value < _PY_NSMALLPOSINTS);
90+
return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS + (int)value];
91+
}
92+
8593
// _PyLong_Frexp returns a double x and an exponent e such that the
8694
// true value is approximately equal to x * 2**e. x is
8795
// 0.0 if and only if the input is 0 (in which case, e and x are both

0 commit comments

Comments
 (0)