C3 Linearization Algorithm
c3linear is a naïve implementation of
C3 linearization
algorithm. C3 used in Python 2.3+ for
Method Resolution Order.
See Raymond Hettinger's
Python’s super() considered super!
for more information.
Motivation
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.
Usage
Library
- Get the code and install it with
python setup.py install(Python 3.6+ required) - Import
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.
Testing
- Install dependencies:
pip install -e .
- (Optional) Install extra packages:
pip install -e .[extra]
- Run tests with:
python setup.py test
- Run
flake8for PEP8 compliance testing:
python setup.py flake8
- Run
mypy:
mypy c3linear/
Contributing
If you've found a bug, please open an issue describing the problem first.
Licence
The project is licensed under MIT License. For further information see
LINCENSE file.
Metadata
Release files for c3linear 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| c3linear-0.1.1.tar.gz | 4.9 kB | Without provenance | Details for c3linear-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| c3linear-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for c3linear-0.1.1-py3-none-any.whl |
Total release size: 11.1 kB
Release files / c3linear-0.1.1.tar.gz
| Download URL | c3linear-0.1.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f2c58d7e47d5b55788092e6eee23b937d56c6af14a404ac11f0cff39cb2c192
|
|
BLAKE2b-256 checksum How to use checksums |
3b60f34b2300987e1bd7f81cbf1bdd1e0830e94ef061a6e5373a6ae7d333fc96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5
|
Release files / c3linear-0.1.1-py3-none-any.whl
| Download URL | c3linear-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a13317aa4cee953638409fda054979960aed54873fb34cf2b41a341ca5cec3f
|
|
BLAKE2b-256 checksum How to use checksums |
d2df439be04fae57dee88c386e3067678da6dbbea90c90ea3488868e2d84ee1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5
|
Security for c3linear 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.