Finding the instance reference of an object

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Nov 7 12:38:11 EST 2008


On Fri, 07 Nov 2008 11:37:28 -0500, Steve Holden wrote:

> Steven D'Aprano wrote:
>> On Fri, 07 Nov 2008 10:50:55 -0500, Steve Holden wrote:
>> 
>>> I am probably egregiously misunderstanding. The practical difficulty
>>> with the "moving huge blocks of data" approach would appear to emerge
>>> when a function that gets passed an instance of some container then
>>> calls another function that references the same container as a global,
>>> for example.
>> 
>> I have no doubt whatsoever that such an implementation would be
>> fragile, complicated, convoluted and slow. In other words, it would be
>> terrible. But that's merely a Quality of Implementation issue. It would
>> still be Python.
>> 
>> 
> OK, more specifically: I don't see how changes to the copy of the
> (structure referenced by) the argument would be reflected in the global
> structure. In other words, it seems to involve a change of semantics to
> me, so I think I am misunderstanding you.

What, you want me to come up with an implementation? Okay, fine.

The VM keeps a list of the namespaces that contain such "cloned" objects. 
After each Python statement is executed, before the next one gets to run, 
the VM runs through that list and synchronizes each object in the 
caller's scope with the value of its clone in the function scope.



-- 
Steven



More information about the Python-list mailing list