Copy constructors

Glyph Lefkowitz glyph at twistedmatrix.com
Sun Aug 12 01:28:47 CEST 2001


On Sat, 11 Aug 2001, Alex Martelli wrote:

> "Glyph Lefkowitz" <glyph at twistedmatrix.com> wrote in message
> news:mailman.997561650.27157.python-list at python.org...
>     ...
> > Am I correct in understanding from this thread that there is an intent to
> > remove the ability to assign an instance's __class__ attribute?
> 
> That's how I'm reading Guido's messages in this thread, too.

OK.  Then I don't regret expressing alarm and causing rioting in the
streets <0.9 wink>.

> I don't know of any better way to handle the Promise design pattern,
> either.  In C++, I'm having to kludge around it all the time via
> letter/envelope idioms -- the possibility of changing classes on the
> fly makes it much simpler and more direct.  Hadn't thought of that
> earlier...

I think the ZODB uses something like this, but it's implemented using
ExtensionClasses.  I'd hate to see it become a requirement to muck around
in native code.

> > twisted.python.rebuild.rebuild, is based entirely upon this "trick".  One
> > of the eye-popping cool features of Python is the ability to change code
> > and have existing instances update to use the new methods automatically.
> 
> That one seems to be related to _another_ capability (of which I've
> seen no indication that it's also going away) -- keeping the same
> class object. but changing that object (rebinding method attributes
> thereof).  Or maybe I don't understand exactly what you mean?

Hmm, I suppose that could be done as well; I'd have to do some other
shuffling around of class references in order to keep isinstance() working
like it should, but you're right: it's not impossible.

> It seems to me the functionality of become is homomorphic to that
> of class-assignment, unless I'm truly missing something major.

Class-assignment + dict-assignment is nearly homomorphic. Of course, if we
could do *real* reference replacement, then you could have a Promise for a
python list :-).

                      ______      __   __  _____  _     _
                     |  ____ |      \_/   |_____] |_____|
                     |_____| |_____  |    |       |     |
                     @ t w i s t e d m a t r i x  . c o m
                     http://twistedmatrix.com/users/glyph






More information about the Python-list mailing list