Skip to main content

bigbrother

Mutation callbacks for Python objects.

Build Status codecov License PyPI

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, and set
  • pydantic.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.

Metadata

Release files for bigbrother 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bigbrother 0.1.5
File Size Uploaded
bigbrother-0.1.5.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bigbrother 0.1.5
File Interpreter ABI Platform
bigbrother-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / bigbrother-0.1.5.tar.gz

Download URL bigbrother-0.1.5.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
84b06ce63c4ed1b6eb470ec1c385bafd6f7b0e18147e980a2fe5536b14b5cda3
BLAKE2b-256 checksum
How to use checksums
647a3eba72d6d04398ac3972e55adf54f2ff1e645b8f0e8134bdb93a694c266c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / bigbrother-0.1.5-py3-none-any.whl

Download URL bigbrother-0.1.5-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e3f9d344944e8d31289d55b9e1ad1977a8768b4ff3aa947ceec488e5f92d300
BLAKE2b-256 checksum
How to use checksums
dcb6dd7625026679293783248a5b7f503e513bfb77ad90eed87319bf4868af4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page