Serpentine Oxidation: Rusty abstractions for Python.
Project description
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:
-
Iterator
combinators that allow for the seamless chaining of operations over data with rayon-inspired functionality for effortless parallelism. -
A
Result
pseudo-enum
comprisingSome
andNull
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. -
An
Option
pseudo-enum
. TheT | 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. -
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 asunwrap_or
(settingNull
to a default value) ormap
(applying a function to the contained value ifSome
).
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")
Acknowledgements
Credit to result and
rustshed for laying the groundwork for the Result
and
qmark
implementations.
Project details
Release history Release notifications | RSS feed
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 serox-0.1.0.tar.gz
.
File metadata
- Download URL: serox-0.1.0.tar.gz
- Upload date:
- Size: 45.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d572eb688464e7e9a5c7c7f56168be5692b1de44d7e563f703569666d825e8ac |
|
MD5 | efcf9e75be37ee3cad334f6edfd8b8e7 |
|
BLAKE2b-256 | 442993b2c75149fb18acaa260c76ec423e639605e1a358450eee517ba27c0315 |
File details
Details for the file serox-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: serox-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9d350e7e0c009dc945a824c365da8215e0c0aabb2aea007e44693f4a2d38d65 |
|
MD5 | f75c7b09e64455db1c08bf2731b60aba |
|
BLAKE2b-256 | 647e351baa4191d4ac6e969d4c4db3b9ea614e8ab68008736c73345251b227b2 |