Georg Brandl <ge...@python.org> added the comment: > That seems a little strange to me, because if an object is instance of > a class, it should inherit all of it attributes.
An instance does not "inherit" attributes of its class. Instead, when looking up an attribute for an instance, attributes of the class (most prominently methods) are considered after looking in the instance __dict__. > Is it an optimization issue? because I observed that all > instances of a class that has such "static" attributes, shares that > attributes for less memory using. No, this has nothing to do with optimization. The main point, which may be surprising if you come from a background of more static languages, is that in Python, the class itself is an object of its own right, and can have attributes (it has its own __dict__). Therefore, class attributes exist only once, and appear to be "shared" when accessed through a class instance. ---------- nosy: +georg.brandl _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7968> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com