C3 Linearization Algorithm
The project has come to life as a byproduct of debugging an overcomplicated hierarchy of mixin classes. I thought I knew how exactly MRO is computed, but it turned out I didn't.
I've tried to keep the code idiomatic and easy to follow at the expense of performance. The project is really took a couple of hours to complete. Although I didn't care about time complexity and didn't check correctness as thoroughly as I should, I think the project may help someone who wants to learn how Python's Method Resolution Order works.
- Get the code and install it with
python setup.py install(Python 3.6+ required)
from c3linear.mro import mro
- Check against built-in MRO:
>>> class A: pass >>> class B(A): pass >>> mro(B) == B.mro() True
Take a look at
tests for more examples.
- Install dependencies:
pip install -e .
- (Optional) Install extra packages:
pip install -e .[extra]
- Run tests with:
python setup.py test
flake8for PEP8 compliance testing:
python setup.py flake8
If you've found a bug, please open an issue describing the problem first.
The project is licensed under MIT License. For further information see