[issue3690] sys.getsizeof wrong for Py3k bool objects

Mark Dickinson report at bugs.python.org
Fri Mar 19 09:36:31 CET 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

I don't think there's anything worth fixing here.  It's true that getsizeof is sometimes going to return results that are too small, because there are a good few places in the longobject internals where it's not predictable in advance exactly how much space is needed, so memory is overallocated.

The case of the small int 0 is one example of this, but it's far from the only one.  For example, if you multiply a 2-limb long by another 2-limb long the code will always allocate 4 limbs for the result, even though it'll often turn out that the result fits in 3 limbs.  Should sys.getsizeof return base_size + 4 * sizeof_limb in that case, instead of base_size + 3 * sizeof_limb?  That would be difficult to achieve, since long objects don't currently know how much space was actually allocated to hold them.

----------
nosy: +mark.dickinson

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


More information about the Python-bugs-list mailing list