[Python-Dev] Instance variable access and descriptors
arigo at tunes.org
Mon Jun 11 13:06:13 CEST 2007
On Sun, Jun 10, 2007 at 04:13:38AM +0300, Eyal Lotem wrote:
> I must be missing something, as I really see no reason to keep the
> existing semantics other than backwards compatibility (which can be
> achieved by introducing a __fastattr__ or such).
> Can you explain under which situations or find any example situation
> where the existing semantics are desirable?
The existing semantics are essential when dealing with metaclasses.
Many of the descriptors of the 'type' class would stop working without
it. For example, the fact that 'x.__class__' normally gives the type of
'x' for any object x relies on this. Reading the '__dict__' attribute
of types is also based on this. Before proposing changes, be sure you
understand exactly how the following works:
<attribute '__class__' of 'object' objects>
>>> class A(object):
<dictproxy object at 0xb7c98e6c>
<attribute '__dict__' of 'A' objects>
More information about the Python-Dev