Copy constructors

Guido van Rossum guido at python.org
Mon Aug 13 22:46:48 EDT 2001


jasbahr at onebox.com (Jason Asbahr) writes:

> I agree with the general opinion here that having virtual
> as default feels like the more 'Pythonic' solution.  

There must be a misunderstanding.  Alex used C++ virtual functions as
an example where C++ went wrong, as an argument for why dynamicism
should be the default.  In Python, all functions are virtual: you can
always override them in a subclass, and I am not going to change this!

All I want is to disable changes to *existing* classes by default.
You can write your own metaclass that changes the default, or you can
inherit from a dynamic base class -- thus, with very little effort,
you can make all your classes dynamic, if you want to.

If it turns out that this is not sufficient for a wide range of
applications, I'll reconsider the default; but I'd rather not, because
there is a severe run-time penalty for the generally unneeded
dynamicism.

> Also class assignment is a very useful feature.

You will be able to write a metaclass (in C) that allows __class__
assignment, when safe.  If there's enough demand this metaclass will
be built-in.

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



More information about the Python-list mailing list