anything like C++ references?

Stephen Horne intentionally at blank.co.uk
Sun Jul 13 11:11:37 EDT 2003


On 13 Jul 2003 10:37:01 -0400, aahz at pythoncraft.com (Aahz) wrote:

>In article <iqm2hvs77lhe1m71v9b579070khbf0uv0a at 4ax.com>,
>Stephen Horne  <intentionally at blank.co.uk> wrote:
>>
>>One of the few things I hate about Python is that mutable objects are
>>implicitly shared using a reference system whereas immutable objects
>>are not. 
>
>Well, that's incorrect.  *ALL* Python objects are implicitly shared with
>bindings.  The difference is whether updating the value referenced by a
>target requires *re*binding the target or simply updating an object.

Fine - nit-pick.

All you have proven is that it is the distinction between types that
get re-bound and those that don't (rather than the use of references)
that is unnecessarily confusing and error prone.

The wart remains, even if my description was wrong. And even that is a
dubious claim.

A Python user is interested in how an object behaves - not how it is
internally implemented in the interpreter. Immutable objects don't
behave as references - the internal use of references for immutable
objects is basically a lazy copying optimisation and, apart from
performace and a couple of other technicalities (e.g. the 'is'
operator), has no relevance. Certainly it has no relevance to the
point I was making.





More information about the Python-list mailing list