lyst[:None]

Jeff Epler jepler at unpythonic.net
Mon May 26 15:32:26 EDT 2003


On Mon, May 26, 2003 at 06:51:51PM +0000, Bengt Richter wrote:
> That seems to work, but you are creating a long when you add one to sys.maxint.
> Internally, python seems to use [0:sys.maxint] as a synonym for [:] which is
> supposed to get a copy of the whole list. I don't have enough memory to see
> if [0]*sys.maxint +[0] can be created, so that [0:sys.maxint+1] would be required
> to get all of it. Maybe this is an instance of practicality beating purity ;-)
> </nit>

The only system where this is likely to work is one where sizeof(void*) >
sizeof(long).  I don't know of any such platforms that matter. (if one
existed, it would be called "LLP64"* or "P64", as opposed to "LP64" or
"ILP64" -- see http://www.opengroup.org/public/tech/aspen/lp64_wp.htm)

Assume sizeof(void*) == sizeof(long) == 4 (32 bits).  Each Python object is
at least 12 (?) bytes, so you can have at most 357913941 of them in your 4
gigabytes of memory.  This is quite a bit fewer objects than the 2147483647
that sys.maxint allows.

If your void*/long are 64 bits, the situation remains the same: you can
store 1537228672809129301 objects in your 64-exbibyte(? 2**64) memory.
This is still fewer objects than sys.maxint's 9223372036854775807.

Only if long is 32 bits do you run into trouble.  Put 25GB of RAM in your
LLP64 machine and you can allocate more than 2**31-1 objects.  But this is
one reason that nobody sane will actually use the LLP64 model*.

Jeff
* A google search implies that Microsoft may have adopted this approach.
That's why I added the word "sane" in the last paragraph of the message.
See "page 8" (according to google) of 
http://www.csee.umbc.edu/help/architecture/successsoftwaredev.pdf
http://216.239.37.100/search?q=cache:u8qsejf7rAgJ:www.csee.umbc.edu/help/architecture/successsoftwaredev.pdf+microsoft+LP64&hl=en&ie=UTF-8





More information about the Python-list mailing list