Georg Brandl <[EMAIL PROTECTED]> 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?
> 
> Because for typical usage of integers (which doesn't include your
> example), it is more expensive to check if there's already an integer
> with that specific value out there than to create a new one.

Ok, so here's a follow-on question: why doesn't intern() accept integer 
arguments?

If it did then you could do the memory optimisation anywhere it seemed 
worthwhile (and all constant integers could be interned when code is first 
loaded at effectively no expense).
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to