Modifying Class Object
Duncan Booth
duncan.booth at invalid.invalid
Tue Feb 9 05:44:57 EST 2010
"Alf P. Steinbach" <alfps at start.no> wrote:
> A copyable reference is a pointer. That is, a "pointer", in e.g. the
> Java sense,
> and in the general language independent sense, means a copyable
> reference -- as illustrated e.g. in the Stanford computer science
> 101 course page I
> referred you to earlier, with C versus Java pointers illustrated in
> the concrete.
The fact that C style pointers are used internally is an detail of the
CPython implementation.
In CPython objects once created remain in the same memory location (and
their id is their address). Compare that to IronPython where the objects
themselves can move around in memory so they have no fixed address. Try
comparing the IronPython implementation to C pointers and you'll cause a
lot of confusion. e.g. someone might think the id() value is in some way
related to an address.
Ruby implements integers without using any pointers at all: there's nothing
in the Python specification which prevents a Python implementation doing
the same for small integers, in fact I believe it has been tried but wasn't
found to improve performance.
The terminology of 'objects', 'names', 'references' describes an abstract
machine. The Python runtime can implement it in any way it chooses so long
as those semantics are preserved. One implementation involves 'pointers',
but that word implies other baggage which is not a required part of the
model.
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list