Is 'everything' a refrence or isn't it?
Bryan Olson
fakeaddress at nowhere.org
Sat Jan 14 17:02:28 EST 2006
Fredrik Lundh wrote:
> Bryan Olson wrote:
>
>
>>>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.
>
>
> do you want to understand this, or do you just want to argue ?
Both!
I think the following is correct: an object's identity is not part
of its value, while its type is.
> (hint: what might the word "query" mean in this context? can you think
> of a meaning that's compatible with what I wrote?
I don't think usage of "query" is the issue. Python queries
objects for their types; it's now a user-visible feature:
>>> 'hello'.__class__
<type 'str'>
> would concepts like
> "object", "value", "type", and "identity" be radically different on a python
> implementation that used e.g. "true" garbage collection and tagged pointers
> instead of CPython's approach? if so, why?)
Python would still be duck-typed and the type would still be a
property of the object. Implementation-wise and behavior-wise,
Python queries objects for their types.
--
--Bryan
More information about the Python-list
mailing list