2. Object System Enhancements
In a very limited sense, it could be said that the current Python implementation already supports deriving classes from built-in classes. The limitation is rather severe though because there is only one built-in class from which all Python classes must be derived. The goal then is to devise a method for creating additional built-in classes that implement their methods in C but are capable of having those methods overridden in Python. This will allow us to have the best of both world: a fast C implementation in the simple case, but also the ability to specialize the behavior in Python. A second but equally important goal is that a class defined in Python should be virtually indistinguishable from a functionally equivalent class defined in C. Meeting these goals implies the ability to dynamically create new instances of built-in classes. Each of theses newly created class objects has the potential for behaving differently from other class objects like it. This then implies the need for a meta-class object, a class object capable of describing the behavior and attributes of another class object.
To make all of this happen the techniques described above were used to derive a class object from the CType object. A single built-in instance of this object was then created to act as the class of all meta-class objects. This object was called MetaClass. Given the existence of this single MetaClass class object, built-in instances of it can now be instantiated much like the current Python implementation supports the instantiation of built-in type objects. From these ideas, the following statements can be made:
Currently meta-classes are always built-in. There are no provision for dynamically creating meta-classes nor is it necessary to do so if all that is desired is to duplicate the current level of functionality available in Python. This extension would be straightforward but imply that syntax changes be made to Python in order to fully support the idea.
Generated with CERN WebMaker