Copy constructors
Roman Suzi
rnd at onego.ru
Sat Aug 11 02:36:32 EDT 2001
On Sat, 11 Aug 2001, Guido van Rossum wrote:
>"Alex Martelli" <aleaxit at yahoo.com> writes:
>
>> "Joal Heagney" <s713221 at student.gu.edu.au> wrote in message
>> news:3B73B115.9981318D at student.gu.edu.au...
>> ...
>> > I LOVE this language. Alex, you're empty class trick just made it into
>> > my private python scrap-book.
>>
>> Glad you liked it! That convinced me to post it as a recipe to the
>> cookbook, with slightly more complete discussion -- please see
>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66507
>> Comments, ratings and feedback are welcome, as usual!
>
>While I probably introduced this myself (pickle uses it), I have one
>reservation. Assignment to self.__class__ is unique to Python -- it's
>not an idiom one can easily translate to other languages. It's also a
>relatively new Python feature (I don't even know if Jython supports
>it).
>
>But maybe more importantly, I don't know how to support this esoteric
>feature after the type/class unification is complete. Under the new
>system, not all instances are born the same: instances may have slots
>for instance variables rather than a __dict__ -- using slots makes for
>more space-efficient instances. (Having a __dict__ is still the
>default, and an instance can have both slots and a __dict__.)
Couldn't slots just be mapped to __dict__ in case somebody accesses it?
Will __dict__ reflect available slots?
I know that Python docs never guarateed __dict__ to be the same forever,
but it is used in classes to do attribute assignments in __setattr__ and
similar circumstances...
Then slots are statically-named attributes (if I understood correctly).
Maybe it will be honest to give some kind of __attrlist__ attribute which
will be similar to __dict__ but devoted to those static slots?
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Saturday, August 11, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "After a hard day, it's nice to come home to a warm cat." _/
More information about the Python-list
mailing list