> > Does this mean that __setattr__
> > incurs the same performance penalty that overriding __getattribute__
> > would?
>
> Not quite AFAICT - there's less going on here. Also, getting an
> attribute is (usually at least) more common than setting it.
>
> > Possibly I can live with this because I think that most of what
> > I'm doing is getting attributes, or modifying mutable ones, rather
> > than setting them.
>
> Well... Using the __setattr__/__getattr__ hooks is IMHO the simplest
> solution that can possibly work - far simpler than your previous one at
> least. As far as I'm concerned, and unless some other point of your
> specs make this unusable or unpractical, I'd go for this solution first
> and run a couple benchs on real-life-or-close-to conditions to check if
> the performance hit is acceptable.

I think you're right - I've just tried implementing a simple version
of this in my code and it seems that in the time critical parts of it
__setattr__ isn't called even once. So I think I'll go with this
solution (after having run a few tests).

Thanks for your suggestion!

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

Reply via email to