Ordering enumeration and protocols.
Project description
orderings
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file orderings-1.6.0.tar.gz.
File metadata
- Download URL: orderings-1.6.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d541412b0c91327f8048c7c304ce7f98f991f75772410e70e735887c825f71cd
|
|
| MD5 |
0261fdd049fb1a71921cd385afc45fac
|
|
| BLAKE2b-256 |
f9a6018c9cd1ea815e09a49afbf2189f7366a1cadff1313c9a6c1c02b7532013
|
File details
Details for the file orderings-1.6.0-py3-none-any.whl.
File metadata
- Download URL: orderings-1.6.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87a1e391449de4835da25e914d0c84fe254db4b069c477fd74f64914d74058b9
|
|
| MD5 |
acc91f776a2bae6af52e03e8d81e9cd6
|
|
| BLAKE2b-256 |
2f1c7c3d7c928871b8da59e5100d1919ce2a9397134d7882e8906450f6c29971
|