Skip to content

Commit 2d6ee26

Browse files
committed
add comment and use Py_ssize_t
1 parent d55868f commit 2d6ee26

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Include/internal/pycore_long.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ PyObject *_PyLong_Add(PyLongObject *left, PyLongObject *right);
4747
PyObject *_PyLong_Multiply(PyLongObject *left, PyLongObject *right);
4848
PyObject *_PyLong_Subtract(PyLongObject *left, PyLongObject *right);
4949

50-
int _PyLong_AssignValue(PyObject **target, long value);
50+
int _PyLong_AssignValue(PyObject **target, Py_ssize_t value);
5151

5252
/* Used by Python/mystrtoul.c, _PyBytes_FromHex(),
5353
_PyBytes_DecodeEscape(), etc. */

Objects/longobject.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,26 +263,26 @@ _PyLong_FromSTwoDigits(stwodigits x)
263263
}
264264

265265
int
266-
_PyLong_AssignValue(PyObject **target, long value)
266+
_PyLong_AssignValue(PyObject **target, Py_ssize_t value)
267267
{
268268
PyObject *old = *target;
269269
if (IS_SMALL_INT(value)) {
270-
*target = get_small_int(Py_SAFE_DOWNCAST(value, long, sdigit));
270+
*target = get_small_int(Py_SAFE_DOWNCAST(value, Py_ssize_t, sdigit));
271271
Py_XDECREF(old);
272272
return 0;
273273
}
274274
else if (old != NULL && PyLong_CheckExact(old) &&
275275
Py_REFCNT(old) == 1 && Py_SIZE(old) == 1 &&
276-
(unsigned long)value <= PyLong_MASK)
276+
(size_t)value <= PyLong_MASK)
277277
{
278278
// Mutate in place if there are no other references to the old object.
279279
// This avoids an allocation in a common case.
280280
((PyLongObject *)old)->ob_digit[0]
281-
= Py_SAFE_DOWNCAST(value, long, digit);
281+
= Py_SAFE_DOWNCAST(value, Py_ssize_t, digit);
282282
return 0;
283283
}
284284
else {
285-
*target = PyLong_FromLong(value);
285+
*target = PyLong_FromSsize_t(value);
286286
Py_XDECREF(old);
287287
if (*target == NULL) {
288288
return -1;

Python/ceval.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4510,6 +4510,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
45104510
if (_PyLong_AssignValue(&GETLOCAL(_Py_OPARG(next)), value) < 0) {
45114511
goto error;
45124512
}
4513+
// The STORE_FAST is already done.
45134514
JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + 1);
45144515
NOTRACE_DISPATCH();
45154516
}

0 commit comments

Comments
 (0)