low-level python hacker and author of RPyC,Construct and Plumbum. writes
about python, algorithms,
software architecture and whatever else comes to mind.
The normal python paradigm for implementing mixins is using multiple inheritance. Mixin classes
take some measures of precaution as of their design (not to interfere with the derivee’s MRO as
much as possible), but they are essentially just regular classes, being derived from.
This code here creates real mixed-in classes: it actually merges one class into another
(CPython specific), taking care of name-mangling, some complications with __slots__, and
everything else. As a side-effect, you can also use it to mix modules into classes.