Message76495
There are a number of places in Objects/stringobject.c where memory is
allocated for a string of length n using:
PyObject_MALLOC(sizeof(PyStringObject) + n)
On my computer (OS X 10.5.5/Intel), and, I suspect, on most common
platforms, the PyStringObject struct is going to contain some number of
bytes (probably 3) of trailing padding; the result is that the
PyObject_MALLOC call above asks for 3 more bytes than are necessary, and
on average the Python interpreter will waste 3 bytes of memory per string
allocation. Is there any reason not to replace these calls with:
PyObject_MALLOC(offsetof(PyStringObject, ob_sval) + n + 1)
instead?
Patch attached. |
|
Date |
User |
Action |
Args |
2008-11-27 12:15:01 | mark.dickinson | set | recipients:
+ mark.dickinson |
2008-11-27 12:15:01 | mark.dickinson | set | messageid: <1227788101.62.0.102470807499.issue4445@psf.upfronthosting.co.za> |
2008-11-27 12:14:44 | mark.dickinson | link | issue4445 messages |
2008-11-27 12:14:43 | mark.dickinson | create | |
|