[Python-Dev] behavior of inplace operations
David Abrahams
David Abrahams" <david.abrahams@rcn.com
Wed, 12 Jun 2002 11:35:02 -0400
From: "Guido van Rossum" <guido@python.org>
> > That's right. I would have suggested that for persistent containers,
the
> > object returned carries its own write-back knowledge.
>
> But that's not how it works. Giving each container a persistent
> object ID is not an option.
I'm sure this is moot, but I don't think I was suggesting that. I was
suggesting that a persistent container's __getitem__() returns a proxy
object which contains a reference back to the container. You can either
write-back upon modifying the object, or, I suppose, upon __del__(). My
scheme may not work (I don't really understand the Zope requirements or
implementation), but it seems that the existing one is just as vulnerable
in the case of a container of mutable objects:
x = container_of_lists[2]
x += 3 # no write-back
-Dave