
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Python implementation of Hybrid Logical Clock.
Requires Python version >= 3.7.
You can install this package from PyPI:
$ pip install hlcpy
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
Based on: https://www.cse.buffalo.edu/tech-reports/2014-04.pdf
Inspired by:
FAQs
Hybrid Logical Clock in Python
We found that hlcpy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.