[Python-Dev] regrtest.py mystery

Guido van Rossum guido@python.org
Mon, 17 Dec 2001 19:15:59 -0500


> > Python doesn't let you replace a reference to an object with something
> > else -- except in special cases (e.g. with explicit weak refs) there's
> > no way to know where references to an object might exist.
> 
> I was too fuzzy in my choice of words. What I meant was not
> finding and replacing the references, but replacing the object to
> which all of the 'dangling references' point.
> 
> But that won't work either: Python objects share the same head, but
> total size of the object structs are too variable, and I don't know
> it's possible to make the minimal size object show the required
> behaviour.

In general it's impossible.  You can't even replace the type pointer
with a pointer to a dummy type, because it would leak any objects
referenced from the original object, and it would break if the
original object lived in a special free list.

> If the problem was important enough, I think a way could be found
> around those problems above, but I'm still not sure that module
> unloading isn't a solution looking  for a problem!

Well, there are a bunch of people who want to undo a partial import,
and that boils down to about the same thing.

--Guido van Rossum (home page: http://www.python.org/~guido/)