Skip to main content

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

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

indifference-0.2.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

indifference-0.2.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

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

Hashes for indifference-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fd2bd51dbf1d4879627724b0a034d81561bf1f8994294b7af8f5c05a8cecd48d
MD5 500515d20f8247dd7832ef6ceb693152
BLAKE2b-256 c7395976ce7a6905029a11cbb2c6a13b31a28cac6f324f4cd39326cb346e3cd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for indifference-0.2.0.tar.gz:

Publisher: publish.yaml on Bobronium/indifference

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for indifference-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a94ff7f81c04d6f07ec64f1e0acddb5d08e0ca8cf5e8c566479666893b37f18b
MD5 06582d8b5a589af47ff4aa0ab33a47db
BLAKE2b-256 1884f534f042ca0ca1a37f27f4508ede6c60e64b973f81b57adf828eb9c4e884

See more details on using hashes here.

Provenance

The following attestation bundles were made for indifference-0.2.0-py3-none-any.whl:

Publisher: publish.yaml on Bobronium/indifference

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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