Re: space effecient representations of list subsets (addendum)

Jaap Vermeulen (jaap@sequent.com)
Fri, 03 Dec 93 13:31:00 PST

| Note that:
...
| The fact that it does the "right" thing here - that the constant
| "1"'s are the same object while different from another object
| with value = "1" is interesting, and I guess a result of
| how python compiles constants in it's intermediate code.

A little more probing shows the following behavior:

>>> id(1)
440532
>>> id(2)
440532
>>>

What's happening here? The id() function is unique *as long as the object
lives*. As soon as the object is garbage collected, the same id can be used
for another object. It still doesn't explain Steven's observation, though:

>>> if id(1) == id(1): print 'OK'
...
OK
>>> if id(1) == id(2): print 'OK'
...
>>>

So probably this is an anomaly as Steven points out.

-Jaap-