Skip to main content

Atomicity is a simple library to provide atomic operation to python's synchronization primitives for multi-threading

Project description

atomicity

PyPI version

Atomicity is a simple library that provides atomic operation to python's synchronization primitives used in multi-threading application.

*** Note: This is at a very early stage and is subject to changes. Use at your own risk. ***

It includes an atomic lock and counter class, ensuring (somewhat) thread-safety and prevention of race conditions in concurrent programming. Everything is entirely lock-free and is backed by Rust's atomic types.

Features

TBD

Installation

Binary wheels are provided for Python 3.8 and above on Linux, macOS, and Windows:

pip install atomicity

On Windows systems, The LLVM Compiler Infrastructure is required

Usage

See the documentation for more information. Here's a quick overview:

Atomic Counter

from atomicity import AtomicCounter

# Create an atomic integer with an initial value of 0
atom = AtomicCounter()

# Perform atomic operations
atom.set(10)
value = atom.get()
print(f"Value: {value}")

previous_value = atom.add( 20)
print(f"Previous Value: {previous_value}")

atom.sub(5)
print(f"Result after addition: {atom}")

# Increment and decrement operations
atom.increment()
atom.decrement()

Atomic Lock

from atomicity import AtomicLock

# Create an atomic boolean with an initial value of False
atom = AtomicLock( False)

# Perform atomic operations
atom.store(True)
value = atom.acquire()
previous_value = atom.release()

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • The atomicity library is heavily dependent on and inspired by the Rust std::sync::atomic module.

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

atomicity-0.0.3.tar.gz (7.1 kB view details)

Uploaded Source

Built Distributions

atomicity-0.0.3-cp310-none-win_amd64.whl (130.1 kB view details)

Uploaded CPython 3.10 Windows x86-64

atomicity-0.0.3-cp310-cp310-manylinux_2_34_x86_64.whl (229.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.34+ x86-64

atomicity-0.0.3-cp310-abi3-manylinux_2_34_x86_64.whl (228.8 kB view details)

Uploaded CPython 3.10+ manylinux: glibc 2.34+ x86-64

File details

Details for the file atomicity-0.0.3.tar.gz.

File metadata

  • Download URL: atomicity-0.0.3.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.4.0

File hashes

Hashes for atomicity-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a677cc33fea972381e30a23c625940fdf4d14a102fc134d44d08312c1b689084
MD5 fd5c3468c1c75f2d0f2d138b54610902
BLAKE2b-256 db9f6c72c1b9b8d039de381b11571c7b556d12ca4d4b795ade54e3edf6c62d42

See more details on using hashes here.

File details

Details for the file atomicity-0.0.3-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for atomicity-0.0.3-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 1ab89d8cd765b095de645124a72041e26ef1195dcf19404f72477d50d8b2ec4f
MD5 eeea1ea440af93fa5366b575e0c9793b
BLAKE2b-256 0c19a0a1aadf3362eba58d6223882f2dff7f4184c2351668838d28a33dc0b6d8

See more details on using hashes here.

File details

Details for the file atomicity-0.0.3-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for atomicity-0.0.3-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8a04ff9ff222ec34d72788f9beaf2e07a9041c69aa586477600867b2dcdc4f52
MD5 603f0d25128f004fde599d0c280662eb
BLAKE2b-256 17aacb303ffed389f06c5e94a391e8e2f30273adabd430ec71aa97ef18412808

See more details on using hashes here.

File details

Details for the file atomicity-0.0.3-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for atomicity-0.0.3-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 35562908e1c9820658fc7f9e1540f4d4f21a7e73786dae72012525d63afe32b7
MD5 88df874fb807fa544e880da4967334de
BLAKE2b-256 a01f06326c7ddd372ddf1e352db2d0ceeb83e8fb0bfe4ddf5ec038a100840bcf

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