[Python-Dev] reference leaks, __del__, and annotations

James Y Knight foom at fuhm.net
Tue Apr 4 21:58:38 CEST 2006


On Apr 3, 2006, at 4:02 PM, Tim Peters wrote:
> Using which compiler?  This varies across boxes.  Most obviously, on a
> 64-bit box all these members are 8 bytes (note that ob_refcnt is
> Py_ssize_t in 2.5, not int anymore), but even on some 32-bit boxes the
> "long double" trick only forces 4-byte alignment.

Hm, yes, my mistake. I see that on linux/x86, long double only takes  
12 bytes and is 4-byte aligned. Even though the actual CPU really  
wants it 8-byte aligned, the ABI has not been changed to allow that.

On OSX/ppc32, OSX/ppc64 and linux/x86-64, doubles are 16 bytes, and 8- 
byte aligned. So the struct uses 16 bytes or 32 bytes, and has the  
extra word of unused space.

All right, then, you could use the top bit of the ob_refcnt field.  
There's no way to possibly have 2**32 objects on a 32bit system anyhow.

James


More information about the Python-Dev mailing list