Atomic Counter
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(base_in_nanos)
c.next() # generate next number in sequence
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.
There is also a TimeCounter class provided. A 64 bit unsigned integer is created that is monotonically increasing, and allows for converting to microseconds to serve as a timestamp (up to the year 2112). Will break if more than 4096 calls to "next" are called within a single microsecond (which is almost assuredly never going to be physically possible, every call makes a system call to get the current time).
from atomic_counter import TimeCounter
from datetime import datetime, timezone
c = TimeCounter()
x = c.next() # generate id
x_time = TimeCounter.to_datetime(x) # generates the datetime where the value was called.
now = datetime.now(timezone.utc)
assert x_time <= now
Metadata
Release files for atomic-counter 0.1.4
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 | |
|---|---|---|---|---|
| atomic_counter-0.1.4.tar.gz | 19.9 kB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| atomic_counter-0.1.4-cp37-abi3-win_amd64.whl | CPython 3.7 | abi3 | Windows x86-64 | Details |
| atomic_counter-0.1.4-cp37-abi3-win32.whl | CPython 3.7 | abi3 | Windows x86-32 | Details |
| atomic_counter-0.1.4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.7 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| atomic_counter-0.1.4-cp37-abi3-macosx_11_0_x86_64.whl | CPython 3.7 | abi3 | macOS 11.0+ x86-64 | Details |
| atomic_counter-0.1.4-cp37-abi3-macosx_11_0_arm64.whl | CPython 3.7 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 929.6 kB
Release files / atomic_counter-0.1.4.tar.gz
| Download URL | atomic_counter-0.1.4.tar.gz |
|---|---|
| Size | 19.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c221aa80581b98c288c6833ac06e0cf74e2081bd40e0e5dcda67f590bc2739bb
|
|
BLAKE2b-256 checksum How to use checksums |
235cddd8b4179739dd1eccad4d60ad7aba0353cecdb63b51d5309f99e9f028a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.10
|
Release files / atomic_counter-0.1.4-cp37-abi3-win_amd64.whl
| Download URL | atomic_counter-0.1.4-cp37-abi3-win_amd64.whl |
|---|---|
| Size | 121.5 kB |
| Tags | CPython 3.7 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1ac8dfc801b14c9759c0e105593765f260abb90ec7d72c0d3be9bc696a621f3a
|
|
BLAKE2b-256 checksum How to use checksums |
ce868f818b379752dd8f0f40e1128fca8454b74c80228f497fa005bc54d39724
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.10
|
Release files / atomic_counter-0.1.4-cp37-abi3-win32.whl
| Download URL | atomic_counter-0.1.4-cp37-abi3-win32.whl |
|---|---|
| Size | 117.0 kB |
| Tags | CPython 3.7 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
1b165e154ac8fd91bc30c10158706946cb8f1296a43f7e450bb09e2f6cc9bfd0
|
|
BLAKE2b-256 checksum How to use checksums |
c8bc37a4de3f7029f314e85f7638eb2d679c91065d6cab6d7f797e79c5fa2a17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.10
|
Release files / atomic_counter-0.1.4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | atomic_counter-0.1.4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 241.2 kB |
| Tags | CPython 3.7 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
358d42034de019d90acd5a3440d643eaa5acf9fe52097c1e7d473d90d62148a7
|
|
BLAKE2b-256 checksum How to use checksums |
f870e706b92cd9be248ff61d8b739b6298f13df9505025a8aff7dc2fc11aa6d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.10
|
Release files / atomic_counter-0.1.4-cp37-abi3-macosx_11_0_x86_64.whl
| Download URL | atomic_counter-0.1.4-cp37-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 220.5 kB |
| Tags | CPython 3.7 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
7a44180f20658079eb5f2847f851fcf42b4518d2d39bcbf147bcd18b7211e5aa
|
|
BLAKE2b-256 checksum How to use checksums |
2ad11035e5ca71740a9553fcc1e07144c29ff9a50d63405d298498b55f8d713e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.10
|
Release files / atomic_counter-0.1.4-cp37-abi3-macosx_11_0_arm64.whl
| Download URL | atomic_counter-0.1.4-cp37-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 209.4 kB |
| Tags | CPython 3.7 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2bf58b0762048ba021c7a6fe6c20d44a970c11896189b88f7aae18f9af38a388
|
|
BLAKE2b-256 checksum How to use checksums |
de1864be6a8c74e1ecd6739432c7e7834506d55a3693c88877f0b3683f380d40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.10
|
Security for atomic-counter 0.1.4
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.