homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Useless addition in PyTuple_New
Type: performance Stage:
Components: Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Jim Nasby, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2015年11月09日 05:44 by Jim Nasby, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Messages (3)
msg254367 - (view) Author: Jim Nasby (Jim Nasby) * Date: 2015年11月09日 05:44
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.
msg254372 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015年11月09日 08:51
There is no such code in current sources.
msg254385 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015年11月09日 12:44
The line "nbytes += " was removed 5 years ago by the changeset 7be8129ee0fd. It's maybe time to update your Python version? :-)
Only Python < 2.7 has the line, it was removed before Python 2.7.0 was tagged.
History
Date User Action Args
2022年04月11日 14:58:23adminsetgithub: 69773
2015年11月09日 12:44:33vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg254385

resolution: fixed
2015年11月09日 08:51:12serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg254372
2015年11月09日 05:44:35Jim Nasbycreate

AltStyle によって変換されたページ (->オリジナル) /