orderings
Ordering enumeration and protocols.
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 on this page — 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
orderings on PyPI
pip
pip install orderingsuv
uv add orderingspoetry
poetry add orderingsInstalling 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 the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — typing-aliases, typing-extensions |
| Maintenance | dormant — 800 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 109,164/month — #12,527 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: orderings-1.6.0-py3-none-any.whl
Keywords: python, ordering
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
logical-unificationLogical unification in Python with support for…
permissive · top 5,000 on PyPI
ordered-enumAdds comparison operators to Python enums so…
unclear · top 15,000 on PyPI
django-ordered-modelAdds ordering and reordering capabilities to…
permissive · top 15,000 on PyPI
mixed-methodsProvides a decorator that lets a single method…
permissive · top 15,000 on PyPI
versionsParses, compares, and validates semantic…
permissive · top 15,000 on PyPI
fractional-indexingGenerates sortable string keys for inserting…
permissive · top 15,000 on PyPI
lexidGenerates lexically ordered numerical IDs that…
permissive · top 15,000 on PyPI
wrapsProvides type-safe wrapper types for…
permissive · top 15,000 on PyPI
async-extensionsProvides utilities and abstractions built on…
permissive · top 15,000 on PyPI