Track and compare differences between Python objects.
Project description
indifference
Track and compare differences between Python objects.
Installation
uv pip install indifference
Usage
import pickle
from copy import deepcopy
from indifference import diff, at
class Person:
def __init__(self, name):
self.name = name
self.cache = {}
self.secret = "hidden"
def __deepcopy__(self, memo):
return self
def __reduce__(self):
# Pickle excludes secret and modifies name
state = {"name": "Bob", "cache": {}}
return (self.__class__, (self.name,), state)
def __setstate__(self, state):
self.__dict__.update(state)
original = Person("Alice")
deepcopy_version = deepcopy(original)
pickle_version = pickle.loads(pickle.dumps(original))
deepcopy_story = diff(original, deepcopy_version)
pickle_story = diff(original, pickle_version)
# Use set operations to find differences
differences = deepcopy_story ^ pickle_story # symmetric difference
common = deepcopy_story & pickle_story # intersection
unique_to_pickle = pickle_story - deepcopy_story
all_changes = deepcopy_story | pickle_story
# Check what's different between the stories
assert differences == [at.name > "Bob"]
Development
- Install Task: https://taskfile.dev
- First run:
task setup - All checks:
task
Project details
Release history Release notifications | RSS feed
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 indifference-0.2.0.tar.gz.
File metadata
- Download URL: indifference-0.2.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd2bd51dbf1d4879627724b0a034d81561bf1f8994294b7af8f5c05a8cecd48d
|
|
| MD5 |
500515d20f8247dd7832ef6ceb693152
|
|
| BLAKE2b-256 |
c7395976ce7a6905029a11cbb2c6a13b31a28cac6f324f4cd39326cb346e3cd5
|
Provenance
The following attestation bundles were made for indifference-0.2.0.tar.gz:
Publisher:
publish.yaml on Bobronium/indifference
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
indifference-0.2.0.tar.gz -
Subject digest:
fd2bd51dbf1d4879627724b0a034d81561bf1f8994294b7af8f5c05a8cecd48d - Sigstore transparency entry: 943860405
- Sigstore integration time:
-
Permalink:
Bobronium/indifference@1309668e1df38ae27928fb2c1afb20ba76348431 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Bobronium
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@1309668e1df38ae27928fb2c1afb20ba76348431 -
Trigger Event:
push
-
Statement type:
File details
Details for the file indifference-0.2.0-py3-none-any.whl.
File metadata
- Download URL: indifference-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a94ff7f81c04d6f07ec64f1e0acddb5d08e0ca8cf5e8c566479666893b37f18b
|
|
| MD5 |
06582d8b5a589af47ff4aa0ab33a47db
|
|
| BLAKE2b-256 |
1884f534f042ca0ca1a37f27f4508ede6c60e64b973f81b57adf828eb9c4e884
|
Provenance
The following attestation bundles were made for indifference-0.2.0-py3-none-any.whl:
Publisher:
publish.yaml on Bobronium/indifference
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
indifference-0.2.0-py3-none-any.whl -
Subject digest:
a94ff7f81c04d6f07ec64f1e0acddb5d08e0ca8cf5e8c566479666893b37f18b - Sigstore transparency entry: 943860419
- Sigstore integration time:
-
Permalink:
Bobronium/indifference@1309668e1df38ae27928fb2c1afb20ba76348431 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Bobronium
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@1309668e1df38ae27928fb2c1afb20ba76348431 -
Trigger Event:
push
-
Statement type: