Skip to content

A CFFI using AtomicLong type for CPython and PyPy.

License

Notifications You must be signed in to change notification settings

benoitc/atomiclong

 
 

Repository files navigation

AtomicLong

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

About

A CFFI using AtomicLong type for CPython and PyPy.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published