[issue4445] String allocations waste 3 bytes of memory on average.

Raymond Hettinger report at bugs.python.org
Thu Nov 27 19:42:25 CET 2008


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

Suggestion:

#define PyStringObject_SIZE (offsetof(PyStringObject, ob_sval) + 1)


 	/* Inline PyObject_NewVar */
-	op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size);
 	/* Inline PyObject_NewVar */
+	op = (PyStringObject *)PyObject_MALLOC(PyStringObject_SIZE + size);

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


More information about the Python-bugs-list mailing list