Git Product home page Git Product logo

pyitc's Introduction

pyitc

Build Status Latest GitHub Release License AGPL-3.0

Python bindings for the libitc library.

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.

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

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!")

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'\x00\t\x01\x02\x01\x00'
print(stamp.id_component.serialise()) # b'\x00\x02'
print(stamp.event_component.serialise()) # b'\x00\x00'

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

License

Released under AGPL-3.0 license, see LICENSE for details.

pyitc's People

Contributors

sdimovv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.