Ordering enumeration and protocols.
Project description
orderings
Ordering enumeration and protocols.
Installing
Python 3.7 or above is required.
pip
Installing the library with pip
is quite simple:
$ pip install orderings
Alternatively, the library can be installed from source:
$ git clone https://github.com/nekitdev/orderings.git
$ cd orderings
$ python -m 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.0.0"
Alternatively, you can add it directly from the source:
[tool.poetry.dependencies.orderings]
git = "https://github.com/nekitdev/orderings.git"
Examples
Core
The core of orderings
is the Ordering
enumeration
and the Compare
protocol:
from attrs import frozen
from orderings import Compare, Ordering
I = TypeVar("I", bound="Int")
@frozen()
class Int(Compare):
value: int
def compare(self: I, other: I) -> Ordering:
self_value = self.value
other_value = other.value
if self_value < other_value:
return Ordering.LESS
if self_value > other_value:
return Ordering.GREATER
return Ordering.EQUAL
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
File details
Details for the file orderings-1.0.0.tar.gz
.
File metadata
- Download URL: orderings-1.0.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cf637d10da2606b6bf98882ef49f3dd35002ccd5388380bb650b5b6858bfe44 |
|
MD5 | 4e77431dd393f0602cc436eb35fa6c14 |
|
BLAKE2b-256 | b53609b003286a18497470bac3c7729dd7629542be3205e4d5ae7da8371e127c |
File details
Details for the file orderings-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: orderings-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8647b77788be6e32efd2d57943575c2eb161571997858f15e9d585e40550868 |
|
MD5 | bddec98fcb4490620b6da79db8a17b63 |
|
BLAKE2b-256 | 0c92e40589d6964b2a10e3ef8078256a49aa09bc9c0eb56d2dad4e4eecc05b4b |