[New-bugs-announce] [issue25587] Useless addition in PyTuple_New

Jim Nasby report at bugs.python.org
Mon Nov 9 00:44:35 EST 2015


New submission from Jim Nasby:

In PyTuple_New, if the new tuple won't go on the free_list:

		/* Check for overflow */
		if (nbytes / sizeof(PyObject *) != (size_t)size ||
		    (nbytes > PY_SSIZE_T_MAX - sizeof(PyTupleObject) - sizeof(PyObject *)))
		{
			return PyErr_NoMemory();
		}
		nbytes += sizeof(PyTupleObject) - sizeof(PyObject *);

nbytes is never used after the overflow check, so the last addition is a waste.

----------
messages: 254367
nosy: Jim Nasby
priority: normal
severity: normal
status: open
title: Useless addition in PyTuple_New
type: performance
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25587>
_______________________________________


More information about the New-bugs-announce mailing list