Is 'everything' a refrence or isn't it?

Bryan Olson fakeaddress at
Sat Jan 14 07:18:02 EST 2006

Fredrik Lundh wrote:
> You're comparing identities, not values.  The value is the set of things that
> you can access via an object's methods (via the type).

Which does make '==' kind of weird. It may or may not refer to
a method of the object.

> The identity is not,
> in itself, a part of the value.
> Python doesn't query the object to determine it's type or identity, but it
> always has to query the object to access the value.
> A look at the C implementation of a typical object might help:
>     typedef struct {
>         int ob_refcnt;
>         struct _typeobject *ob_type; /* type */
>         ... an unknown amount of stuff used to represent the value ...
>     } MyObject;
> In CPython, the MyObject* pointer is the identity.  The ob_refcnt field is a
> CPython implementation detail.  The ob_type field contains the type.

So, was it an editing error when you said that Python does not
query the object to determine its type?  The type is there in the
object, and and in Python, variables and references are not typed.


More information about the Python-list mailing list