durusmail: durus-users: Eliminate __dict__ from persistent btree, bnode, dict, list and set
Eliminate __dict__ from persistent btree, bnode, dict, list and set
Eliminate __dict__ from persistent btree, bnode, dict, list and set
2006-07-05
2006-07-05
2006-07-05
2006-07-06
2006-07-06
2006-07-06
XMPP/Jabber chatting (was: Re: [Durus-users] Eliminate __dict__ from persistent btree, bnode, dict, list and set)
2006-10-31
Re: XMPP/Jabber chatting
2006-10-31
Eliminate __dict__ from persistent btree, bnode, dict, list and set
Patrick K. O'Brien
2006-07-05
Mike Orr wrote:
> On 7/5/06, David Binger  wrote:
>>  Just the other day,
>> someone asked
>> me if it was safe to assign attributes to a PersistentDict:  it is,
>> as long
>> as you avoid "data" and the other inherited names.  Your change would
>> change the answer from "yes, with care" to "no".  I bet that does break
>> some existing code.
>
> I asked about this, so I can put attributes on the root object.
> root.chemicals[1234].name makes more sense than
> root["chemicals"][1234].name, when the number of attributes is few and
> relatively fixed.

In this case I think the memory saving far outweigh the syntactical
nicety that you have achieved.  Schevo makes heavy use of all the
persistent classes for databases that only get bigger, never smaller.

Unfortunately, slots accumulate from subclass to subclass and once
declared cannot be removed.  So the only way to *not* have a __dict__
attribute (which defeats the whole point of slots) is to keep it out of
the lower-level classes as long as possible.  That means the only
practical way to get the benefits of slots is to define them on the
Persistent base class and to not include a __dict__.

In the mean time, I'll just fork and patch Durus for use by Schevo.  The
advantages are simply too significant to pass up.

--
Patrick K. O'Brien
Orbtech       http://www.orbtech.com
Schevo        http://www.schevo.org
Louie         http://www.pylouie.org
reply