Surprise using the 'is' operator

Simon Brunning simon at brunningonline.net
Wed Sep 27 11:40:06 EDT 2006


On 9/27/06, tobiah <toby at tobiah.org> wrote:
> Suppose I fill an list with 100 million random integers in the range
> of 1 - 65535.  Wouldn't I save much memory if all of the ocurrances
> of '12345' pointed to the same integer object?  Why should more be made,
> when they all do the same thing, and are not subject to change?

If you were to drop that list, then to generate another large list of
integers, you'd want to re-use the memory from the first lot, wouldn't
you?

(BTW, AFAIK, integers are kept seperate from other objects
memory-wise, so memory used for integers won'tr be re-used for other
object types. but memory used for integers can be re-used for *other*
integers. I think.)

-- 
Cheers,
Simon B,
simon at brunningonline.net



More information about the Python-list mailing list