orderings


Nameorderings JSON
Version 1.6.0 PyPI version JSON
download
home_pagehttps://github.com/nekitdev/orderings
SummaryOrdering enumeration and protocols.
upload_time2024-06-05 12:18:31
maintainerNone
docs_urlNone
authornekitdev
requires_python>=3.8
licenseMIT
keywords python ordering
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `orderings`

[![License][License Badge]][License]
[![Version][Version Badge]][Package]
[![Downloads][Downloads Badge]][Package]
[![Discord][Discord Badge]][Discord]

[![Documentation][Documentation Badge]][Documentation]
[![Check][Check Badge]][Actions]
[![Test][Test Badge]][Actions]
[![Coverage][Coverage Badge]][Coverage]

> *Ordering enumeration and protocols.*

## Installation

**Python 3.8 or above is required.**

### `pip`

Installing the library with `pip` is quite simple:

```console
$ pip install orderings
```

Alternatively, the library can be installed from source:

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

Or via cloning the repository:

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

### `poetry`

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

```console
$ poetry add orderings
```

Or by directly specifying it in the configuration like so:

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

Alternatively, you can add it directly from the source:

```toml
[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`][orderings.core.Ordering] enumeration
and the [`Compare`][orderings.core.Compare] protocol:

```python
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`][orderings.core.Compare] implements all ordering operations
(`==`, `!=`, `<`, `>`, `<=`, `>=`) using the [`compare`][orderings.core.Compare.compare] method.

## Documentation

You can find the documentation [here][Documentation].

## Support

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

## Changelog

You can find the changelog [here][Changelog].

## Security Policy

You can find the Security Policy of `orderings` [here][Security].

## Contributing

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

## License

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

[Email]: mailto:support@nekit.dev

[Discord]: https://nekit.dev/chat

[Actions]: https://github.com/nekitdev/orderings/actions

[Changelog]: https://github.com/nekitdev/orderings/blob/main/CHANGELOG.md
[Code of Conduct]: https://github.com/nekitdev/orderings/blob/main/CODE_OF_CONDUCT.md
[Contributing Guide]: https://github.com/nekitdev/orderings/blob/main/CONTRIBUTING.md
[Security]: https://github.com/nekitdev/orderings/blob/main/SECURITY.md

[License]: https://github.com/nekitdev/orderings/blob/main/LICENSE

[Package]: https://pypi.org/project/orderings
[Coverage]: https://codecov.io/gh/nekitdev/orderings
[Documentation]: https://nekitdev.github.io/orderings

[Discord Badge]: https://img.shields.io/discord/728012506899021874
[License Badge]: https://img.shields.io/pypi/l/orderings
[Version Badge]: https://img.shields.io/pypi/v/orderings
[Downloads Badge]: https://img.shields.io/pypi/dm/orderings

[Documentation Badge]: https://github.com/nekitdev/orderings/workflows/docs/badge.svg
[Check Badge]: https://github.com/nekitdev/orderings/workflows/check/badge.svg
[Test Badge]: https://github.com/nekitdev/orderings/workflows/test/badge.svg
[Coverage Badge]: https://codecov.io/gh/nekitdev/orderings/branch/main/graph/badge.svg

[orderings.core.Compare]: https://nekitdev.github.io/orderings/reference/core#orderings.core.Compare
[orderings.core.Compare.compare]: https://nekitdev.github.io/orderings/reference/core#orderings.core.Compare.compare
[orderings.core.Ordering]: https://nekitdev.github.io/orderings/reference/core#orderings.core.Ordering


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nekitdev/orderings",
    "name": "orderings",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "python, ordering",
    "author": "nekitdev",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/f9/a6/018c9cd1ea815e09a49afbf2189f7366a1cadff1313c9a6c1c02b7532013/orderings-1.6.0.tar.gz",
    "platform": null,
    "description": "# `orderings`\n\n[![License][License Badge]][License]\n[![Version][Version Badge]][Package]\n[![Downloads][Downloads Badge]][Package]\n[![Discord][Discord Badge]][Discord]\n\n[![Documentation][Documentation Badge]][Documentation]\n[![Check][Check Badge]][Actions]\n[![Test][Test Badge]][Actions]\n[![Coverage][Coverage Badge]][Coverage]\n\n> *Ordering enumeration and protocols.*\n\n## Installation\n\n**Python 3.8 or above is required.**\n\n### `pip`\n\nInstalling the library with `pip` is quite simple:\n\n```console\n$ pip install orderings\n```\n\nAlternatively, the library can be installed from source:\n\n```console\n$ pip install git+https://github.com/nekitdev/orderings.git\n```\n\nOr via cloning the repository:\n\n```console\n$ git clone https://github.com/nekitdev/orderings.git\n$ cd orderings\n$ pip install .\n```\n\n### `poetry`\n\nYou can add `orderings` as a dependency with the following command:\n\n```console\n$ poetry add orderings\n```\n\nOr by directly specifying it in the configuration like so:\n\n```toml\n[tool.poetry.dependencies]\norderings = \"^1.6.0\"\n```\n\nAlternatively, you can add it directly from the source:\n\n```toml\n[tool.poetry.dependencies.orderings]\ngit = \"https://github.com/nekitdev/orderings.git\"\n```\n\n## Motivation\n\nSometimes it's simpler to handle ordering in one method, for example when comparing iterators;\nthen it's trivial to implement the regular ordering methods using the `compare` method.\n\n## Examples\n\n### Core\n\nThe core of `orderings` is the [`Ordering`][orderings.core.Ordering] enumeration\nand the [`Compare`][orderings.core.Compare] protocol:\n\n```python\nfrom typing import Generic, TypeVar\n\nfrom attrs import frozen\nfrom orderings import Compare, Ordered, Ordering, compare\nfrom typing_extensions import Self\n\nT = TypeVar(\"T\", bound=Ordered)\n\n\n@frozen()\nclass Wrap(Compare, Generic[T]):\n    value: T\n\n    def compare(self, other: Self) -> Ordering:\n        return compare(self.value, other.value)\n```\n\n[`Compare`][orderings.core.Compare] implements all ordering operations\n(`==`, `!=`, `<`, `>`, `<=`, `>=`) using the [`compare`][orderings.core.Compare.compare] method.\n\n## Documentation\n\nYou can find the documentation [here][Documentation].\n\n## Support\n\nIf you need support with the library, you can send an [email][Email]\nor refer to the official [Discord server][Discord].\n\n## Changelog\n\nYou can find the changelog [here][Changelog].\n\n## Security Policy\n\nYou can find the Security Policy of `orderings` [here][Security].\n\n## Contributing\n\nIf you are interested in contributing to `orderings`, make sure to take a look at the\n[Contributing Guide][Contributing Guide], as well as the [Code of Conduct][Code of Conduct].\n\n## License\n\n`orderings` is licensed under the MIT License terms. See [License][License] for details.\n\n[Email]: mailto:support@nekit.dev\n\n[Discord]: https://nekit.dev/chat\n\n[Actions]: https://github.com/nekitdev/orderings/actions\n\n[Changelog]: https://github.com/nekitdev/orderings/blob/main/CHANGELOG.md\n[Code of Conduct]: https://github.com/nekitdev/orderings/blob/main/CODE_OF_CONDUCT.md\n[Contributing Guide]: https://github.com/nekitdev/orderings/blob/main/CONTRIBUTING.md\n[Security]: https://github.com/nekitdev/orderings/blob/main/SECURITY.md\n\n[License]: https://github.com/nekitdev/orderings/blob/main/LICENSE\n\n[Package]: https://pypi.org/project/orderings\n[Coverage]: https://codecov.io/gh/nekitdev/orderings\n[Documentation]: https://nekitdev.github.io/orderings\n\n[Discord Badge]: https://img.shields.io/discord/728012506899021874\n[License Badge]: https://img.shields.io/pypi/l/orderings\n[Version Badge]: https://img.shields.io/pypi/v/orderings\n[Downloads Badge]: https://img.shields.io/pypi/dm/orderings\n\n[Documentation Badge]: https://github.com/nekitdev/orderings/workflows/docs/badge.svg\n[Check Badge]: https://github.com/nekitdev/orderings/workflows/check/badge.svg\n[Test Badge]: https://github.com/nekitdev/orderings/workflows/test/badge.svg\n[Coverage Badge]: https://codecov.io/gh/nekitdev/orderings/branch/main/graph/badge.svg\n\n[orderings.core.Compare]: https://nekitdev.github.io/orderings/reference/core#orderings.core.Compare\n[orderings.core.Compare.compare]: https://nekitdev.github.io/orderings/reference/core#orderings.core.Compare.compare\n[orderings.core.Ordering]: https://nekitdev.github.io/orderings/reference/core#orderings.core.Ordering\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Ordering enumeration and protocols.",
    "version": "1.6.0",
    "project_urls": {
        "Chat": "https://nekit.dev/chat",
        "Documentation": "https://nekitdev.github.io/orderings",
        "Funding": "https://nekit.dev/funding",
        "Homepage": "https://github.com/nekitdev/orderings",
        "Issues": "https://github.com/nekitdev/orderings/issues",
        "Repository": "https://github.com/nekitdev/orderings"
    },
    "split_keywords": [
        "python",
        " ordering"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f1c7c3d7c928871b8da59e5100d1919ce2a9397134d7882e8906450f6c29971",
                "md5": "acc91f776a2bae6af52e03e8d81e9cd6",
                "sha256": "87a1e391449de4835da25e914d0c84fe254db4b069c477fd74f64914d74058b9"
            },
            "downloads": -1,
            "filename": "orderings-1.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "acc91f776a2bae6af52e03e8d81e9cd6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6056,
            "upload_time": "2024-06-05T12:18:24",
            "upload_time_iso_8601": "2024-06-05T12:18:24.526484Z",
            "url": "https://files.pythonhosted.org/packages/2f/1c/7c3d7c928871b8da59e5100d1919ce2a9397134d7882e8906450f6c29971/orderings-1.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f9a6018c9cd1ea815e09a49afbf2189f7366a1cadff1313c9a6c1c02b7532013",
                "md5": "0261fdd049fb1a71921cd385afc45fac",
                "sha256": "d541412b0c91327f8048c7c304ce7f98f991f75772410e70e735887c825f71cd"
            },
            "downloads": -1,
            "filename": "orderings-1.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0261fdd049fb1a71921cd385afc45fac",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5359,
            "upload_time": "2024-06-05T12:18:31",
            "upload_time_iso_8601": "2024-06-05T12:18:31.841178Z",
            "url": "https://files.pythonhosted.org/packages/f9/a6/018c9cd1ea815e09a49afbf2189f7366a1cadff1313c9a6c1c02b7532013/orderings-1.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-05 12:18:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nekitdev",
    "github_project": "orderings",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "orderings"
}
        
Elapsed time: 0.28572s