Hello Oscar,

thanks for your help but your proposal of adding:

def __setitem__(self,key,value):
   self.__dict__[key] = value
   dict.__setitem__(self, key, value)

does not help me.

What I have today is a class that works like SlowStorage. I want to
replace it with NewStorage because it is 10x faster. That is the only
reason. NewStorage does everything I want and all the APIs work like
SlowStorage except casting to dict.

By defining __setitem__ as you propose, you solve the casting to dict
issue but you have two unwanted effects: each key,value is store twice
(in different places), accessing the elements becomes slower the
SlowStprage which is my problem in the first place.

The issue for me is understanding how the casting dict(obj) works and
how to change its behavior so that is uses methods exposed by obj to
do the casting, if all possible.

Massimo

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to