--- id: orderings version: "1.6.0" license: MIT license_treatment: permissive maintenance: dormant --- # orderings — Ordering enumeration and protocols. License: permissive · Maintenance: dormant · Downloads: 109.2K/mo ## What it is and what it does orderings is a small library that centralizes comparison logic by providing an Ordering enumeration and a Compare protocol. Instead of implementing six separate comparison methods (`__eq__`, `__lt__`, etc.), you define a single `compare` method that returns an Ordering value, and the Compare protocol automatically derives all comparison operations from it. This is particularly useful when you already have a natural ordering function and want to avoid boilerplate. The package depends on typing-aliases and typing-extensions to support type hints across Python 3.8 and newer. It is fully typed and marked Production/Stable, though development has been dormant since mid-2024. The library is small and self-contained, making it a low-risk addition for projects that benefit from a unified comparison interface. Use it for: - Implement comparison for custom classes by writing one compare method instead of six dunder methods. - Build ordered wrapper types that delegate comparison to an inner value using the Compare protocol. - Simplify comparison logic where a natural ordering function already exists. - Reduce boilerplate in data structures that need full ordering support but have a single comparison rule. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides an Ordering enumeration and Compare protocol to unify comparison logic into a single method, letting you implement all ordering operations (`==`, `!=`, `<`, `>`, `<=`, `>=`) from one compare function. Yes, if you are writing classes that need full comparison support and prefer a single compare method over six dunder methods. The low install friction, permissive MIT license, and lack of security issues make it safe to add. The dormant maintenance is not a blocker for a stable, narrow-scope library, but verify that the Compare protocol integrates well with your existing type hierarchy before committing. ## Install pip install orderings uv add orderings poetry add orderings ## Installing orderings Before you install: Low friction: pure Python wheel with only two lightweight runtime dependencies. Dormant maintenance since June 2024, though repository remains active and marked Production/Stable. License in practice: MIT license (permissive) places no restrictions on use, modification, or distribution in commercial or private projects. Quickstart: pip install orderings from orderings import Compare, Ordering from typing_extensions import Self class MyComparable(Compare): def __init__(self, value): self.value = value def compare(self, other: Self) -> Ordering: if self.value < other.value: return Ordering.Less elif self.value > other.value: return Ordering.Greater else: return Ordering.Equal Requires Python 3.8 or above. Verify before relying: - Whether the Compare protocol integrates cleanly with existing comparison frameworks or requires explicit class inheritance. - Performance characteristics when Compare is used in large-scale sorting or comparison-heavy workloads. - Real-world adoption patterns and whether the dormant status indicates the library has reached stable maturity or lacks active maintenance. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 109.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags ordering enumeration protocol, comparison unification, compare method implementation, ordering operations, unified comparison logic, comparison-protocol, type-hints [View on SkillFed](https://skillfed.io/packages/orderings) · [View on PyPI](https://pypi.org/project/orderings/)