skillfed

orderings

Ordering enumeration and protocols.

orderings v1.6.0 109.2K downloads/30d#12,527 on PyPI2
Permissive license MIT DORMANT released

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 orderings

uv

uv add orderings

poetry

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 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: UtilitiesTyping :: Typed

Tags

ordering enumeration protocolcomparison unificationcompare method implementationordering operationsunified comparison logic
comparison-protocoltype-hints

More Utilities packages