How to test if an object IS another object?
Grant Edwards
grante at visi.com
Sun Jun 12 17:37:33 EDT 2005
On 2005-06-12, eloff777 at yahoo.com <eloff777 at yahoo.com> wrote:
> Fascinating. With small strings, it uses the same object, and with
> small numbers like 3. With 300 they were different objects (why,
It's purely an implimentation detail. The small integers get
used a lot, so Python keeps a pre-created set of small integers
handy. It would be a bit, uh, wasteful to pre-create all of
possible integer objects, so "large" integers get created on
the fly without checking to see if there are any existing ones
with the right value. Large integers could get cached and
re-used, but that would be extra overhead with little chance
for benefit.
> shouldn't they both be ints still?)
They are.
--
Grant Edwards grante Yow! .. over in west
at Philadelphia a puppy is
visi.com vomiting...
More information about the Python-list
mailing list