Class.__class__ magic trick help
Massimo Di Pierro
massimo.dipierro at gmail.com
Tue Aug 21 09:50:17 EDT 2012
More information about the Python-list mailing list
Tue Aug 21 09:50:17 EDT 2012
- Previous message (by thread): Class.__class__ magic trick help
- Next message (by thread): Class.__class__ magic trick help
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): Class.__class__ magic trick help
- Next message (by thread): Class.__class__ magic trick help
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list