{"id":23284,"library":"atomic-dict","title":"atomic-dict","description":"A lock-free shared memory dictionary for 64-bit integer keys and values, built on atomic operations. Version 0.5.0 supports Python >=3.10. Frequently updated with minor releases.","status":"active","version":"0.5.0","language":"python","source_language":"en","source_url":"https://github.com/terpstra/atomic-dict","tags":["atomic","lock-free","shared-memory","dict","concurrency"],"install":[{"cmd":"pip install atomic-dict","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Used for type hinting Self type","package":"typing_extensions","optional":false}],"imports":[{"note":"Hyphen not valid in Python identifiers, use underscore.","wrong":"from atomic-dict import AtomicDict","symbol":"AtomicDict","correct":"from atomic_dict import AtomicDict"}],"quickstart":{"code":"from atomic_dict import AtomicDict\n\n# Create a shared memory dictionary (requires admin privileges on some systems)\nd = AtomicDict()\n# Set a value for integer key 42\nd[42] = 12345\n# Get the value\nprint(d[42])  # 12345\n# Compare-and-swap (key 42 from 12345 to 54321)\nd.compare_and_swap(42, 12345, 54321)\nprint(d[42])  # 54321","lang":"python","description":"Basic usage: create an AtomicDict, set/get integer keys, and use compare_and_swap."},"warnings":[{"fix":"Ensure keys and values are within -2^63 to 2^63-1.","message":"AtomicDict only supports integer keys and values (64-bit). Passing floats, strings, or other types will raise an error or have undefined behavior.","severity":"gotcha","affected_versions":"all"},{"fix":"Run with appropriate privileges or configure system limits (e.g., increase memlock on Linux).","message":"Creating an AtomicDict may require root/admin privileges on some operating systems (e.g., Linux CAP_IPC_LOCK or Windows SeLockMemoryPrivilege). On systems without privileges, initialization may fail with permission errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Use 'clear()' instead of 'reset()'.","message":"The function 'reset()' was renamed to 'clear()' in version 0.3.0. Using 'reset()' raises an AttributeError.","severity":"deprecated","affected_versions":">=0.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from atomic_dict import AtomicDict'.","cause":"Trying to import via 'import atomic_dict' and then using 'atomic_dict.AtomicDict' but possibly package name inconsistency.","error":"AttributeError: module 'atomic_dict' has no attribute 'AtomicDict'"},{"fix":"Run as root or increase memlock limit via 'ulimit -l unlimited'.","cause":"The library uses shared memory (mmap with MAP_SHARED) which may require elevated privileges on Linux.","error":"PermissionError: [Errno 1] Operation not permitted"},{"fix":"Convert values to 64-bit integers before assignment.","cause":"Attempting to store a non-integer value (e.g., float or string) in the dictionary.","error":"TypeError: only integer values are allowed"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}