For a more visual example of the implied objectsuperclass in 3.0, and other examplesof diamond patterns created by it, see the ListTreeclass’s output in the lister.pyexamplein the preceding chapter, as well as the classtree.pytree walker example in Chapter 28.New-Style Class ExtensionsBeyond the changes described in the prior section (which, frankly, may be too academicand obscure to matter to many readers of this book), new-style classes provide a handfulof more advanced class tools that have more direct and practical application. The fol-lowing sections provide an overview of each of these additional features, available fornew-style class in Python 2.6 and all classes in Python 3.0.Instance SlotsBy assigning a sequence of string attribute names to a special __slots__class attribute,it is possible for a new-style class to both limit the set of legal attributes that instancesof the class will have and optimize memory and speed performance.This special attribute is typically set by assigning a sequence of string names to thevariable __slots__at the top level of a classstatement: only those names in the__slots__list can be assigned as instance attributes. However, like all names in Python,instance attribute names must still be assigned before they can be referenced, even ifthey’re listed in __slots__. For example:>>> class limiter(object):... __slots__ = ['age', 'name', 'job']...>>> x = limiter()>>> x.age# Must assign before useAttributeError: age>>> x.age = 40>>> x.age40>>> x.ape = 1000# Illegal: not in __slots__AttributeError: 'limiter' object has no attribute 'ape'Slots are something of a break with Python’s dynamic nature, which dictates that anyname may be created by assignment. However, this feature is envisioned as both a wayto catch “typo” errors like this (assignments to illegal attribute names not in__slots__are detected), as well as an optimization mechanism. Allocating a namespace