A class decorator can create new methods using a two-step process. First, it must create a method function and then insert it into the class definition. This is often better done via a mixin class than a decorator. The obvious and expected use of a mixin is to insert methods. Inserting methods with a decorator is less obvious and can be astonishing to people reading the code and trying to find where the methods of a class are defined.
In the example of the Total_Ordering decorator, the exact method functions inserted were flexible and depended on what was already provided. This was a kind of special case that doesn't tend to astonish people reading the code.
We'll look at a technique to create a snapshot of an object's state by creating a text memento of the object. This can be implemented via a standardized memento() method. We'd...