An AtomicLong type using CFFI.
Project description
Sometimes you need to increment some numbers … atomically … in python.
AtomicLong was born out of the need for fast thread-safe counters in python.
It uses CFFI to bind GCC’s Atomic Builtins.
Its value is a C long which can be incremented, decremented, and set atomically. It is inspired by Java’s java.util.concurrent.atomic.AtomicLong.
Example:
>>> from atomiclong import AtomicLong >>> a = AtomicLong(0) >>> a += 1 >>> a.value 1 >>> a += 10 >>> a.value 11 >>> a.value = 1000 >>> a.value 1000 >>> a -= 100 >>> a.value 900
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
atomiclong-0.1.1.tar.gz
(5.1 kB
view details)
File details
Details for the file atomiclong-0.1.1.tar.gz.
File metadata
- Download URL: atomiclong-0.1.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb1378c4cd676d6f243641c50e277504abf45f70f1ea76e446efcdbb69624bbe
|
|
| MD5 |
1cb5dac8191060069f34a13cb868ed4c
|
|
| BLAKE2b-256 |
868c70aea8215c6ab990f2d91e7ec171787a41b7fbc83df32a067ba5d7f3324f
|