Module for defining reversible transactions.
Project description
carnot
carnot is a module that enables reversible transactions for general purposes. Reversible transactions may make your codes simpler and have better readability inspite of complicated logics.
Installing
- Python >= 3.8
python -m pip install carnot
Usage
from carnot import reversible_function, transaction
count = 0
@reverse_function
def add(num: int) -> None:
global count
count += num
add.set_args(num)
@add.backward
def _add(num: int) -> None:
global count
count -= num
@transaction
def add_and_emit_error() -> None:
add(2)
raise Exception
if __name__ == "__main__":
try:
add_and_emit_error()
except:
pass
finally:
print(count) # 0
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
carnot-0.1.1.tar.gz
(3.2 kB
view details)
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 carnot-0.1.1.tar.gz.
File metadata
- Download URL: carnot-0.1.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
436f238ed482fda332ec993801280f05eccc82b2a7b2370d8373a835daa5084b
|
|
| MD5 |
8eaebc53451bb33c1eced9d2f9fbec4a
|
|
| BLAKE2b-256 |
d66ea0c47d4e400cc74c2d4885f20c2809010849382639b93550913c971a1619
|
File details
Details for the file carnot-0.1.1-py3-none-any.whl.
File metadata
- Download URL: carnot-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b351a674c86e84115050b106754f247f7df819a0f11cc5a90e3dd62ae7672bb
|
|
| MD5 |
eb7cc65558fc5a054b6ab55109fe4c17
|
|
| BLAKE2b-256 |
a9c6253c961b982e7806f23623ad5152184157a83fe9792e531d507c1bab56ab
|