Skip to main content

Python bindings for the libitc library

Project description

pyitc

Build Status Latest GitHub Release License AGPL-3.0

Python bindings for the libitc library.

Table Of Contents

What Are Interval Tree Clocks?

Interval Tree Clocks (ITC) are a generalisation of the Vector Clock and Version Vector mechanisms, allowing for scalable and efficient management of a highly dynamic number of replicas/processes in a distributed system.

See the ITC research paper from Paulo Sérgio Almeida, Carlos Baquero and Victor Fonte for more information.

Features

  • Provides easy-to-use, Pythonesque bindings for the underlying C library
  • Provides __str__ methods for easy visualisation of the ITC trees
  • Provides bindings for the C lib's "extended API"
  • Uses 64-bit event counters

Getting Started

Prerequisites

Download and install the wheels/sdist from PyPI or GitHub.

Usage Examples

Here are some usage examples:

from pyitc import Stamp, StampComparisonResult
from pyitc.extended_api import Id, Event

stamp = Stamp()
stamp.event()

stamp2 = stamp.fork()

print(stamp) # {(0, 1); 1}
print(stamp.peek()) # {0, 1}
print(stamp2) # {(1, 0); 1}

if stamp == stamp2: # all comparision operators are supported
    print("yay!")
else:
    print("nay")

if stamp.compare_to(stamp2) == StampComparisonResult.EQUAL: # equivalent to stamp == stamp2
    print("yay again!")

stamp2.event() # Make stamp2 concurrent with stamp

if stamp.compare_to(stamp2) == StampComparisonResult.CONCURRENT:
    print("Oh no! What should we do now?")

stamp3 = stamp2.fork()

stamp2.join(stamp3)

if not stamp3.is_valid():
    print("stamp3 was joined with stamp2 and is no longer valid!")

print(stamp.id_component) # (0, 1)
print(stamp.event_component) # 1

stamp.event_component = Event()
stamp.id_component = Id(seed=True)

print(stamp.serialise()) # b'\x01\t\x01\x02\x01\x00'
print(stamp.id_component.serialise()) # b'\x01\x02'
print(stamp.event_component.serialise()) # b'\x01\x00'

remote_stamp = Stamp.deserialise(b'...')
remote_event = Event.deserialise(b'...')
remote_id = Id.deserialise(b'...')

Contributing

See CONTRIBUTING.md.

Reporting Vulnerabilities

:warning: NEVER open public issues or pull requests to report or fix security vulnerabilities.

See the Security Policy.

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

pyitc-1.0.0.tar.gz (145.9 kB view hashes)

Uploaded Source

Built Distributions

pyitc-1.0.0-pp310-pypy310_pp73-win_amd64.whl (67.9 kB view hashes)

Uploaded PyPy Windows x86-64

pyitc-1.0.0-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (59.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

pyitc-1.0.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (61.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyitc-1.0.0-pp39-pypy39_pp73-win_amd64.whl (67.9 kB view hashes)

Uploaded PyPy Windows x86-64

pyitc-1.0.0-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (59.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

pyitc-1.0.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (61.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyitc-1.0.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl (53.9 kB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

pyitc-1.0.0-pp39-pypy39_pp73-macosx_10_15_x86_64.whl (54.9 kB view hashes)

Uploaded PyPy macOS 10.15+ x86-64

pyitc-1.0.0-pp38-pypy38_pp73-win_amd64.whl (67.9 kB view hashes)

Uploaded PyPy Windows x86-64

pyitc-1.0.0-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (59.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

pyitc-1.0.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (61.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyitc-1.0.0-pp38-pypy38_pp73-macosx_11_0_arm64.whl (53.9 kB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

pyitc-1.0.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (54.5 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pyitc-1.0.0-cp38-abi3-win_amd64.whl (74.0 kB view hashes)

Uploaded CPython 3.8+ Windows x86-64

pyitc-1.0.0-cp38-abi3-musllinux_1_2_x86_64.whl (66.4 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ x86-64

pyitc-1.0.0-cp38-abi3-musllinux_1_2_i686.whl (67.8 kB view hashes)

Uploaded CPython 3.8+ musllinux: musl 1.2+ i686

pyitc-1.0.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (65.2 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

pyitc-1.0.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (66.3 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyitc-1.0.0-cp38-abi3-macosx_11_0_arm64.whl (59.2 kB view hashes)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

pyitc-1.0.0-cp38-abi3-macosx_10_9_x86_64.whl (60.5 kB view hashes)

Uploaded CPython 3.8+ macOS 10.9+ x86-64

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