A library for object observability
Project description
bigbrother
An evil, awful, terrible, no-good library for watching objects for mutation. Do not use this library.
Overview
bigbrother
is a mutation observer library. You can use it to watch your objects for changes. When your object changes, bigbrother
will trigger your choice of callback.
x = {1: "a", 2: "b", 3: "c"}
def track_changes(obj, method, *args, **kwargs):
print(f"method: {method}, args: {args}, kwargs: {kwargs}")
x = watch(x, track_changes)
x[1] = "x"
# prints: method: setitem, args: (1, 'x'), kwargs: {}
bigbrother
can also embed itself recursively in your object by passing in argument deepstate=True
.
Supported types
Builtins
Most builtin types are read-only and cannot have their method structure mutated, so we observe via replacement with thin wrappers.
list
via_ObservedList
append
clear
extend
insert
pop
remove
sort
__setattr__
__setitem__
dict
via_ObservedDict
clear
pop
popitem
update
__setattr__
__setitem__
set
via_ObservedSet
add
clear
difference_update
discard
intersection_update
pop
remove
symmetric_difference_update
update
__setattr__
Libraries
pydantic.BaseModel
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
bigbrother-0.1.2.tar.gz
(19.3 kB
view hashes)
Built Distribution
bigbrother-0.1.2-py3-none-any.whl
(18.7 kB
view hashes)
Close
Hashes for bigbrother-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35000bc233968cc3081674d8613744b717ce1c063eb081ea3e074cf4d972ee3a |
|
MD5 | 9e9f05fb4e08d725158686a60331f688 |
|
BLAKE2b-256 | 14fa99403bf3b0e16a94b80b50929213e8b53fdbaf522a00c7baca5175afa6f0 |