3 ms·
> CPython could do both; allocations are usually not byte-perfect Though it's probably not the case for strings, it should be noted that for most objects alloc
by masklinn 6y ago
> CPython could do both; allocations are usually not byte-perfect
Though it's probably not the case for strings, it should be noted that for most objects allocations are byte-perfect, because the average Python object is a bunch of pointers and and a refcount: two gc pointers, a refcount, a weakref pointer, a class pointer and a dict pointer, for a total of 48 bytes (as of 3.9, ignoring all the pointees).
That's not the case for `__slots__` though: they drop the instance dict and the weakref pointer, but then each field will add a pointer to the total (then again that's space which won't be allocated as part of the instance dict).