Skip to main content

orderings

License Version Downloads Discord

Documentation Check Test Coverage

Ordering enumeration and protocols.

Installation

Python 3.8 or above is required.

pip

Installing the library with pip is quite simple:

$ pip install orderings

Alternatively, the library can be installed from source:

$ pip install git+https://github.com/nekitdev/orderings.git

Or via cloning the repository:

$ git clone https://github.com/nekitdev/orderings.git
$ cd orderings
$ pip install .

poetry

You can add orderings as a dependency with the following command:

$ poetry add orderings

Or by directly specifying it in the configuration like so:

[tool.poetry.dependencies]
orderings = "^1.6.0"

Alternatively, you can add it directly from the source:

[tool.poetry.dependencies.orderings]
git = "https://github.com/nekitdev/orderings.git"

Motivation

Sometimes it's simpler to handle ordering in one method, for example when comparing iterators; then it's trivial to implement the regular ordering methods using the compare method.

Examples

Core

The core of orderings is the Ordering enumeration and the Compare protocol:

from typing import Generic, TypeVar

from attrs import frozen
from orderings import Compare, Ordered, Ordering, compare
from typing_extensions import Self

T = TypeVar("T", bound=Ordered)


@frozen()
class Wrap(Compare, Generic[T]):
    value: T

    def compare(self, other: Self) -> Ordering:
        return compare(self.value, other.value)

Compare implements all ordering operations (==, !=, <, >, <=, >=) using the compare method.

Documentation

You can find the documentation here.

Support

If you need support with the library, you can send an email or refer to the official Discord server.

Changelog

You can find the changelog here.

Security Policy

You can find the Security Policy of orderings here.

Contributing

If you are interested in contributing to orderings, make sure to take a look at the Contributing Guide, as well as the Code of Conduct.

License

orderings is licensed under the MIT License terms. See License for details.

Release files for orderings 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for orderings 1.6.0
File Size Uploaded
orderings-1.6.0.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for orderings 1.6.0
File Interpreter ABI Platform
orderings-1.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / orderings-1.6.0.tar.gz

Download URL orderings-1.6.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d541412b0c91327f8048c7c304ce7f98f991f75772410e70e735887c825f71cd
BLAKE2b-256 checksum
How to use checksums
f9a6018c9cd1ea815e09a49afbf2189f7366a1cadff1313c9a6c1c02b7532013
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / orderings-1.6.0-py3-none-any.whl

Download URL orderings-1.6.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87a1e391449de4835da25e914d0c84fe254db4b069c477fd74f64914d74058b9
BLAKE2b-256 checksum
How to use checksums
2f1c7c3d7c928871b8da59e5100d1919ce2a9397134d7882e8906450f6c29971
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page