What other languages use the same data model as Python?

Chris Angelico rosuav at gmail.com
Tue May 10 05:35:22 EDT 2011


On Tue, May 10, 2011 at 12:29 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> If objects can be in two places at once, why can't names? Just because.

Because then you'd need some way to identify which object you wanted
to refer to - something like name[0] and name[1]. A tuple is one
effective way to do this (sort of - actually, the name points at the
tuple and the tuple points at each of the objects).

On Tue, May 10, 2011 at 12:47 PM, MRAB <python at mrabarnett.plus.com> wrote:
> I had heard something about the meaning of the word "gift", so I
> checked in Google Translate. For Swedish "gift" it says:
>
> noun
> 1. POISON
> 2. VENOM
> 3. TOXIN
> 4. VIRUS

Beware of Swedes bearing gifts!

On Tue, May 10, 2011 at 5:41 PM, Gregory Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Anonymous objects are fine. You just draw a little box and
> don't write any label beside it. Or you don't bother drawing
> a little box at all and just draw a big box until such time
> as some little box that you care about needs to point to it.
>
> If that's a problem, then you have the same problem talking
> about names bound to objects. An anonymous object obviously
> doesn't have any name bound to it. So you have to admit that
> objects can exist, at least temporarily, without being bound
> to anything, or bound to some anonymous thing.

There has to be a way to get from some mythical "home" location (which
we know in Python as locals()+globals()+current expression - the
"current namespace") to your object. That might involve several names,
or none at all, but if there's no such path, the object is
unreferenced and must be disposed of. IIRC that's not just an
implementation detail (the garbage collector), but a language
guarantee (that the __del__ method will be called).

Names are immaterial to that.

Chris Angelico



More information about the Python-list mailing list