serox


Nameserox JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummarySerpentine Oxidation: Rusty abstractions for Python.
upload_time2024-11-12 22:09:56
maintainerNone
docs_urlNone
authorMyles Bartlett
requires_python>=3.12
licenseNone
keywords iterators option protocols python result rust structural-typing traits types typing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Serox

_Rusty abstractions for Python._

`Serox` defines a emulates a suite of commonly-used Rust abstractions in a manner that is near-fully
static-type-checker compliant, the exceptions being cases involving higher-kinded types (HKTs; e.g.
`Iterator.collect`) as these are not currently supported by Python's type system. Namely:

1. `Iterator` combinators that allow for the seamless chaining of operations over data with
   [rayon]-inspired functionality for effortless parallelism.
2. A `Result` pseudo-`enum` comprising `Some` and `Null` pseudo-variants. We say 'pseudo' as the
   Python analogue to Rust's tagged union is the union (`A | B`) type; since this type is not a data
   structure, we cannot implement methods on it directly and instead have to resort to some
   legerdemain.

3. An `Option` pseudo-`enum`. The `T | None` pattern is ubiquitous in Python yet, frustratingly, is
   not treated as a first-class citizen within the language; `Option` is a drop-in replacement that
   redresses this.

4. The `qmark` decorator emulates the '?' (error/null short-circuiting) operator, allowing for
   propagation of error and null values without interrupting the control flow. Without this, one has
   to resort to awkward pattern-matching to perform common operations such as `unwrap_or` (setting
   `Null` to a default value) or `map` (applying a function to the contained value if `Some`).

```python
from serox import Option, qmark

@qmark
def some_function(foo: Option[str]) -> Option[str]:
    foo_bar: str = value.map(lambda x: x + "bar").q
    return Some(foo_bar + "_baz")
```

[rayon]: https://github.com/rayon-rs/rayon

## Acknowledgements

Credit to [result](https://github.com/rustedpy/result) and
[rustshed](https://github.com/pawelrubin/rustshed/) for laying the groundwork for the `Result` and
`qmark` implementations.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "serox",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "iterators, option, protocols, python, result, rust, structural-typing, traits, types, typing",
    "author": "Myles Bartlett",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/ca/d9/926a50fe1735f181d912ca04c5753f064f5119232800a19328a26d38b2af/serox-0.1.1.tar.gz",
    "platform": null,
    "description": "# Serox\n\n_Rusty abstractions for Python._\n\n`Serox` defines a emulates a suite of commonly-used Rust abstractions in a manner that is near-fully\nstatic-type-checker compliant, the exceptions being cases involving higher-kinded types (HKTs; e.g.\n`Iterator.collect`) as these are not currently supported by Python's type system. Namely:\n\n1. `Iterator` combinators that allow for the seamless chaining of operations over data with\n   [rayon]-inspired functionality for effortless parallelism.\n2. A `Result` pseudo-`enum` comprising `Some` and `Null` pseudo-variants. We say 'pseudo' as the\n   Python analogue to Rust's tagged union is the union (`A | B`) type; since this type is not a data\n   structure, we cannot implement methods on it directly and instead have to resort to some\n   legerdemain.\n\n3. An `Option` pseudo-`enum`. The `T | None` pattern is ubiquitous in Python yet, frustratingly, is\n   not treated as a first-class citizen within the language; `Option` is a drop-in replacement that\n   redresses this.\n\n4. The `qmark` decorator emulates the '?' (error/null short-circuiting) operator, allowing for\n   propagation of error and null values without interrupting the control flow. Without this, one has\n   to resort to awkward pattern-matching to perform common operations such as `unwrap_or` (setting\n   `Null` to a default value) or `map` (applying a function to the contained value if `Some`).\n\n```python\nfrom serox import Option, qmark\n\n@qmark\ndef some_function(foo: Option[str]) -> Option[str]:\n    foo_bar: str = value.map(lambda x: x + \"bar\").q\n    return Some(foo_bar + \"_baz\")\n```\n\n[rayon]: https://github.com/rayon-rs/rayon\n\n## Acknowledgements\n\nCredit to [result](https://github.com/rustedpy/result) and\n[rustshed](https://github.com/pawelrubin/rustshed/) for laying the groundwork for the `Result` and\n`qmark` implementations.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Serpentine Oxidation: Rusty abstractions for Python.",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [
        "iterators",
        " option",
        " protocols",
        " python",
        " result",
        " rust",
        " structural-typing",
        " traits",
        " types",
        " typing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2bf0b23c6f0abc2ec6b686e21f5f4f98b57f76e0c570b0b3465eb31127c92891",
                "md5": "b5cd7d608ccf679814e7c31360dfd1f8",
                "sha256": "60b8d427b02f929cdb4fe4c10dc931d45045627551b477018d8bdb12ff73b4d0"
            },
            "downloads": -1,
            "filename": "serox-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b5cd7d608ccf679814e7c31360dfd1f8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 26528,
            "upload_time": "2024-11-12T22:09:54",
            "upload_time_iso_8601": "2024-11-12T22:09:54.714488Z",
            "url": "https://files.pythonhosted.org/packages/2b/f0/b23c6f0abc2ec6b686e21f5f4f98b57f76e0c570b0b3465eb31127c92891/serox-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cad9926a50fe1735f181d912ca04c5753f064f5119232800a19328a26d38b2af",
                "md5": "3dc4ae38cf6a0836195555f904230fd7",
                "sha256": "e2d6d126666b284d373a5ceb3864cf8e194fe5261d924d048b192bae13927e13"
            },
            "downloads": -1,
            "filename": "serox-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3dc4ae38cf6a0836195555f904230fd7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 45907,
            "upload_time": "2024-11-12T22:09:56",
            "upload_time_iso_8601": "2024-11-12T22:09:56.851481Z",
            "url": "https://files.pythonhosted.org/packages/ca/d9/926a50fe1735f181d912ca04c5753f064f5119232800a19328a26d38b2af/serox-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-12 22:09:56",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "serox"
}
        
Elapsed time: 0.48596s