Copy constructors
Roman Suzi
rnd at onego.ru
Sun Aug 12 16:44:58 EDT 2001
On Sun, 12 Aug 2001, Guido van Rossum wrote:
>> (Regarding the __dynamic__=1, as discussed on another post, I have a
>> different issue, namely, what should the default be; it seems to me
>> that builtins being immutable as a default, and only changed via
>> explicit mechanisms, is a fine match for the patterns of normal
>> code, but *classes* being immutable by default and needing explicit
>> turning off of this optimization isn't quite as smooth).
>
>A dynamic class will be slower than a static class, so I prefer having
>to request this explicitly. But we can certainly quibble about that!
>I expect that the new facilities will be seriously user-tested only
>after 2.2 is released, and experience will learn how often people are
>changing class variables.
<< dynamic-on-demand >>
I think that only builtin (written in C) classes must be static by
default. The inability to change class's variables will remove some of the
Python niceness, when it is possible to _simply_ add/remove attributes
to/from classes and instances. This adds a lot of freedom.
Maybe it is possible to inherit builtin methods from builtin classes
without so restricting measures? (When dynamics is turned on not by some
__dynamic__ = 1, but by the fact of inheritance from builtin class.
This why one can still inherit, but this will cause some slowdown.
If I understand correctly, C-functions are speedy, because they find atts
in the static places and user-defined classes use costly lookups.
Maybe it was already suggested, but probably __dynamic__ could be changed
implicitely: when access which need dynamics occurs. Before that, class is
speedy and static (but potentially dynamic - dynamic-on-demand ;-)
This way most of classes will remain speedy (if they do not override but
add) but those which chose to make deeper changes will pay by longer
lookups after the first access swithes class __dynamic__ on.
And it will all be implicit and nobody notices!
(I hope it not total nonsense)
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Sunday, August 12, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Is it possible to feel gruntled?" _/
More information about the Python-list
mailing list