A library for object observability
Project description
bigbrother
Mutation callbacks for Python objects.
bigbrother watches mutable Python objects and calls your callback when they
change. It is useful when another layer needs to mark state dirty, schedule a
refresh, or react to model changes without replacing every mutation call.
Install
pip install bigbrother
Example
from bigbrother import watch
changes = []
def track_change(obj, method, ref, call_args, call_kwargs):
changes.append((method, call_args, call_kwargs))
state = watch({"items": []}, track_change, deepstate=True)
state["items"].append("alpha")
assert changes[-1] == ("append", ("alpha",), {})
Keep the object returned by watch(). Built-in containers are observed by
returning watched container instances.
Supported Objects
bigbrother supports:
list,dict, andsetpydantic.BaseModel- plain Python objects and dataclasses with a
__dict__
Objects without a __dict__, such as slot-only classes, are returned unchanged.
Callbacks fire before the underlying mutation completes.
Documentation
Development
make develop
python -m pytest bigbrother/tests -q
License
bigbrother is licensed under Apache-2.0.
[!NOTE] This library was generated using copier from the Base Python Project Template repository.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bigbrother-0.1.5.tar.gz.
File metadata
- Download URL: bigbrother-0.1.5.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84b06ce63c4ed1b6eb470ec1c385bafd6f7b0e18147e980a2fe5536b14b5cda3
|
|
| MD5 |
94199029b3cf0d08bfdd52460fe6dc60
|
|
| BLAKE2b-256 |
647a3eba72d6d04398ac3972e55adf54f2ff1e645b8f0e8134bdb93a694c266c
|
File details
Details for the file bigbrother-0.1.5-py3-none-any.whl.
File metadata
- Download URL: bigbrother-0.1.5-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e3f9d344944e8d31289d55b9e1ad1977a8768b4ff3aa947ceec488e5f92d300
|
|
| MD5 |
27cc63814073f2ed5c60b4910b131e62
|
|
| BLAKE2b-256 |
dcb6dd7625026679293783248a5b7f503e513bfb77ad90eed87319bf4868af4b
|