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.1.0.tar.gz (12.4 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.1.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file indifference-0.1.0.tar.gz.

File metadata

  • Download URL: indifference-0.1.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for indifference-0.1.0.tar.gz
Algorithm Hash digest
SHA256 14bec20bedb0faba00c30cfcb42499d451c56ca895616791a71c7326d8b54642
MD5 dc3ded1b3e21ffec0321698c3c504627
BLAKE2b-256 a20f0ec4043536a78ab42789fd57ae57b545d14c8f44a7e02b93b8b7c0472a80

See more details on using hashes here.

Provenance

The following attestation bundles were made for indifference-0.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: indifference-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e2995fd9be87f419f759fb185912e6499edf3b474e2f51616487ce1702d63cb
MD5 7e73b8b0637fe59834dca840ef4db3e2
BLAKE2b-256 08235d603e3a3baf5827a35825ee9efbd2a13d5fd151254a51686c5b4dfbf957

See more details on using hashes here.

Provenance

The following attestation bundles were made for indifference-0.1.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