Eliminate __dict__ from persistent btree, bnode,
dict, list and set
David Binger
2006-07-06
On Jul 5, 2006, at 9:27 PM, Patrick K. O'Brien wrote:
> David Binger wrote:
>>
>> On Jul 5, 2006, at 7:59 PM, Patrick K. O'Brien wrote:
>>
>>>
>>> I have one idea. Instead of PersistentDict.data being a dict, it
>>> could
>>> be a subclass of dict. Then __setstate__ could test the incoming
>>> state
>>> to see if it is a regular dict or our special subclass. But that
>>> would
>>> trade off physical disk savings against type inspection within
>>> __setstate__, which gets called a lot. I'm not sure that would be
>>> worthwhile. The alternative would be a one-time conversion routine.
>>> Unless you think of something better.
>>
>> It does not help PersistentSet or PersistentList as your idea does,
>> but it might be possible to make PersistentDict use the actual
>> __dict__
>> value as the dict instead of wrapping another dict instance.
>>
>> I think I remember trying to make PersistentDict be a dict as you
>> suggest here, and I felt like it was getting difficult to understand.
>
> I'm not sure we're talking about the exact same thing. My idea was
> something like this:
We're not. I was thinking that *maybe* PersistentDict could be
defined to use the normal self.__dict__ *directly* for holding
keys and values instead of using any self.data, slot or otherwise.
I'm not talking here about making PersistentDict a subclass of dict.
I think that might be dangerous because c extensions might use
direct c-based dict methods if they find that PersistentDict X passes
the isinstance(dict, X) test.