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.0.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file carnot-0.1.0.tar.gz
.
File metadata
- Download URL: carnot-0.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 636921e18136d98fea202fbc4f494fc27f3b35ce87250b107c7c564aa698ce3f |
|
MD5 | 3724ee5d2f24d1e54dea680d5359cf0d |
|
BLAKE2b-256 | d593d764cec14a27d0f4d100d64ff82c18a95d729a02286a166a4c4876f28ecc |
File details
Details for the file carnot-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: carnot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a78be8cbb49ab174586047b657ab7e5dbea4e07bcfeff86d118639e6604402d0 |
|
MD5 | b43de0da6f2005eb6f77a3a0cc8b3999 |
|
BLAKE2b-256 | e6b7efa4583a6fc1382bbbed4b5280def9a1961e38a322082ef623e9eaf62da3 |