File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -1289,8 +1289,13 @@ PyObject *
1289
1289
_PyType_AllocNoTrack (PyTypeObject * type , Py_ssize_t nitems )
1290
1290
{
1291
1291
PyObject * obj ;
1292
+ /* The +1 on nitems is needed for most types but not all. We could save a
1293
+ * bit of space by allocating one less item in certain cases, depending on
1294
+ * the type. However, given the extra complexity (e.g. an additional type
1295
+ * flag to indicate when that is safe) it does not seem worth the memory
1296
+ * savings. An example type that doesn't need the +1 is a subclass of
1297
+ * tuple. See GH-100659 and GH-81381. */
1292
1298
const size_t size = _PyObject_VAR_SIZE (type , nitems + 1 );
1293
- /* note that we need to add one, for the sentinel */
1294
1299
1295
1300
const size_t presize = _PyType_PreHeaderSize (type );
1296
1301
char * alloc = PyObject_Malloc (size + presize );
You can’t perform that action at this time.
0 commit comments