Skip to main content

Atomic Counters

Project description

Atomic Counter

Build Status Coverage License PyPI

Overview

atomic-counter is a rust library for generating a monotonically increasing sequence of integers. Depending on the particular configuration of the counter, the generated sequence will be produce unique numbers down to the nanosecond, regardless of memory state. E.g. if you quit the process and recreate a new counter >1ns later, your sequence is guaranteed to still be monotonically increasing (but with a gap).

Usage

from atomic_counter import Counter

c = Counter(offset_in_nanos, base_in_nanos)

c.next()  # generate next number in sequence

Here, base is the counter's 0 value (e.g. a epoch in nanos to consider the 0 point, to keep numbers as small as possible if you do not need to go back to 1970). offset is the number of nanos since base at which to start.

If unset, base will be 2010-01-01 in nanos, offset will be 0, which means the counter will start at (now - 2010/01/01) as nanos.

To create e.g. a daily counter, pass in base=today in nanos. As this is a common occurrence for sequences that reset daily, a convenience function def daily() -> Counter: is provided.

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

atomic_counter-0.1.3.tar.gz (17.9 kB view details)

Uploaded Source

Built Distributions

atomic_counter-0.1.3-cp37-abi3-win_amd64.whl (115.6 kB view details)

Uploaded CPython 3.7+ Windows x86-64

atomic_counter-0.1.3-cp37-abi3-win32.whl (113.3 kB view details)

Uploaded CPython 3.7+ Windows x86

atomic_counter-0.1.3-cp37-abi3-musllinux_1_2_x86_64.whl (295.0 kB view details)

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

atomic_counter-0.1.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (234.1 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

atomic_counter-0.1.3-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (243.5 kB view details)

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

atomic_counter-0.1.3-cp37-abi3-macosx_11_0_arm64.whl (201.8 kB view details)

Uploaded CPython 3.7+ macOS 11.0+ ARM64

File details

Details for the file atomic_counter-0.1.3.tar.gz.

File metadata

  • Download URL: atomic_counter-0.1.3.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for atomic_counter-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1d7dc516776fd9d45de97b8179ebe2e7f5f8edb017ce1d769ff6cd0c6edeff12
MD5 6872d769b6599cbcdc5bebf843deb2b3
BLAKE2b-256 d288334a44d65150068d5b6d013f9067f1e432e8e92f92bc411a826f61c8c30c

See more details on using hashes here.

File details

Details for the file atomic_counter-0.1.3-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for atomic_counter-0.1.3-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 104d42eaf71061863dec03e92b9449f891d076d9b71d0ae1341b00a742bf547d
MD5 03388b7a4bd006e0ef689e0bd7b6261c
BLAKE2b-256 521292132786ed74638c6f35a094329a4aecbe9a7abafacc46134dad75e7c462

See more details on using hashes here.

File details

Details for the file atomic_counter-0.1.3-cp37-abi3-win32.whl.

File metadata

File hashes

Hashes for atomic_counter-0.1.3-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 a1b138c4c687424db8d4a33f73a2e1f6f18912a28a34548f860ac9d8f3c864f1
MD5 effb30f99bdf4c5bf21377d7993d8cd9
BLAKE2b-256 4baca2cda0031c664064e92d20426b3b8f8ee63557cd94c7c4447f630b4b29d2

See more details on using hashes here.

File details

Details for the file atomic_counter-0.1.3-cp37-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for atomic_counter-0.1.3-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5142d3fdbffcf39db444760d8ef9a40141adf6f752bffeb0b1cb4f923f7d37f4
MD5 9c8ba09f267ecd1e3d6179ee88b89e21
BLAKE2b-256 63689c5735dbec801f49348996660da11b762e335260729dc1a098719518c0fc

See more details on using hashes here.

File details

Details for the file atomic_counter-0.1.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for atomic_counter-0.1.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 680c44a9a8b33f5cfb9481e54816029550394da097a2fa43c3f6cbc9d85c08f7
MD5 cdcd2294fa6115ae5fa4b37ee8b8bca9
BLAKE2b-256 0c599d57538dd257688ab1453e0ea436784c6ba15c35e0229e7e65d5415d5654

See more details on using hashes here.

File details

Details for the file atomic_counter-0.1.3-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for atomic_counter-0.1.3-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 cc8772175a41c16bbea15e40909a51584cc00c47d6067c7abe18fcbec6397b50
MD5 f2f71d4df51ae2c53c2051140aa7eaef
BLAKE2b-256 4b0ad54beefd3e0773f57dbc6102edacbc0fc8f501dd98b8f073e9fde7c51947

See more details on using hashes here.

File details

Details for the file atomic_counter-0.1.3-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for atomic_counter-0.1.3-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 65679c35ddc098b0ed66887bee59aac8c17748ee0d84de8b23baba34836141aa
MD5 56d7b3b784687a688d965839e3512ce2
BLAKE2b-256 74384e873209a419f665431287c961c0da4bc0c1799c44f4add208ee2d34004b

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