Skip to main content

Advisory-only setattr hooks with veto support

Project description

Reaktome

Reaktome is a CPython extension that installs advisory hooks on Python’s built-in containers (list, dict, set).
It allows you to observe and react to mutations without subclassing or replacing types.


Features

  • Patch individual instances of built-in containers.
  • Hook into mutations (append, pop, __setitem__, etc.).
  • Hooks are called after the mutation (advisory only).
  • Works per-instance via an internal side-table.

Example

import _reaktome

def on_additem(self, key, old, new):
    print(f"{self} added {new}")

lst = []
_reaktome.patch_list(lst, {"__reaktome_additem__": on_additem})

lst.append(42)
# Output: [] added 42

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

reaktome-0.1.22.tar.gz (21.1 kB view details)

Uploaded Source

File details

Details for the file reaktome-0.1.22.tar.gz.

File metadata

  • Download URL: reaktome-0.1.22.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for reaktome-0.1.22.tar.gz
Algorithm Hash digest
SHA256 ab808cf274b841d523977bd4951cf2dbb5a896abd60c0710fea06043369276aa
MD5 124324a8e0ce250a2bd4093f133096d3
BLAKE2b-256 eba35a21d26288f897235414418624e6768bb4e2460a1be4230c3e782f44db27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page