Hybrid Logical Clock
Python implementation of Hybrid Logical Clock.
Requires Python version >= 3.7.
You can install this package from PyPI:
$ pip install hlcpy
Exemplary usage
import hlcpy
# BASIC USAGE
# Instantiate HLC
c = hlcpy.HLC()
# specify starting nanos and logical time
c = hlcpy.HLC(nanos=123, logical=0)
# create from current time
c = hlcpy.HLC.from_now()
# create from iso8601 time
c = hlcpy.HLC.from_str('2020-01-01T00:00:00Z')
# string representation of HLC
print(str(c))
#>>> 2020-01-01T00:00:00.000000000Z_0
# create from string representation
c1 = hlcpy.HLC.from_str(str(c))
# refresh the clock
c.sync()
# supports comparison
print(c > c1)
#>>> True
# merge two events
c.merge(c1)
print(c)
#>>> 2021-04-24T18:42:47.001864924Z_0
# merge event that occured in the future see the logical tick
import time
future = hlcpy.HLC(nanos=int(time.time_ns() + 3e9))
c.merge(future)
print(c)
#>>> 2021-04-24T18:42:50.001891328Z_1
# More examples - see tests/unit/test_hlc.py
Credits
Based on: https://www.cse.buffalo.edu/tech-reports/2014-04.pdf
Inspired by:
- https://www.youtube.com/watch?v=iEFcmfmdh2w
- https://github.com/adsharma/hlcpy (based on but heavily rewritten)
- https://bartoszsypytkowski.com/hybrid-logical-clocks/
Metadata
Release files for hlcpy 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hlcpy-0.0.2.tar.gz | 5.4 kB | Without provenance | Details for hlcpy-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hlcpy-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for hlcpy-0.0.2-py3-none-any.whl |
Total release size: 11.5 kB
Release files / hlcpy-0.0.2.tar.gz
| Download URL | hlcpy-0.0.2.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7cacb14023642a29177156ad95fc3f9b563265f18a4849354ae496f7b5a50af0
|
|
BLAKE2b-256 checksum How to use checksums |
993f11c2be144063646071dfe4ddaa3e1d718dca8a30a3e24993918f9389071d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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.9.4
|
Release files / hlcpy-0.0.2-py3-none-any.whl
| Download URL | hlcpy-0.0.2-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
628542deb30f62737dbc883de08bfd440cf59111583b3e8b13a6c049bf59ecbf
|
|
BLAKE2b-256 checksum How to use checksums |
3169818251620eaa95cd920e44fb7ac2af69f8534874565d8642d0a14506282a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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.9.4
|
Security for hlcpy 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.