Skip to main content

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


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)

Uploaded Source

Built Distribution

carnot-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for carnot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 636921e18136d98fea202fbc4f494fc27f3b35ce87250b107c7c564aa698ce3f
MD5 3724ee5d2f24d1e54dea680d5359cf0d
BLAKE2b-256 d593d764cec14a27d0f4d100d64ff82c18a95d729a02286a166a4c4876f28ecc

See more details on using hashes here.

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

Hashes for carnot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a78be8cbb49ab174586047b657ab7e5dbea4e07bcfeff86d118639e6604402d0
MD5 b43de0da6f2005eb6f77a3a0cc8b3999
BLAKE2b-256 e6b7efa4583a6fc1382bbbed4b5280def9a1961e38a322082ef623e9eaf62da3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page