Bruno Desthuilliers <[EMAIL PROTECTED]> writes: >> However, if you know what you're doing, you can simply customize your >> class's __getattribute__ to do what *you* want for your objects. > > <op> > But bear in mind that, beside possible unwanted side-effectn, you'll > get a non-negligible performance hit - __getattribute__ being, as the > name implies, invoked on each and every attribute lookup.
That's unavoidable, though -- whatever you do to customize your class in Python, the result will be slower than the C code built into Python. Fortunately, not every object is performance-critical. In this case, __getattribute__ buys you per-instance customization not otherwise available. The code you posted is probably more efficient, but at the cost of losing the ability to customize specific instances of the class. -- http://mail.python.org/mailman/listinfo/python-list