[Python-Dev] Re: Re: Int FutureWarnings and other 2.4 TODOs
Fred L. Drake, Jr.
fdrake at acm.org
Thu Dec 4 11:30:19 EST 2003
Andrew Koenig writes:
> An int is a 31-bit integer, INCLUDING sign. One extra bit indicates whether
> the integer is really a number or, alternatively, a pointer to the rest of
> the representation.
> Now, you may object that implementing this strategy in C will require lots
> of shifting and masking. I would have thought so, too. However, every C
> implementation of which I am aware puts all but the most trivial data
> structures on boundaries of two or more bytes. This fact frees the
> LOW-order bit of the integer to indicate whether it is a pointer.
I recently mentioned this approach to coaxing an extra bit from an
existing structure to Tim, and he pointed out (rightly!) that this
only works for machines with byte-addressable memories. On
word-addressable memories, there's no chance to coax the extra bit
from a pointer at all, and Python still runs on at least one such
platform (some Cray thing, IIRC).
Otherwise I like the approach. ;-)
Fred L. Drake, Jr. <fdrake at acm.org>
PythonLabs at Zope Corporation
More information about the Python-Dev