Skip to main content

Recursive subset comparison for complex nested Python data structures

Project description

deepset - Recursive Subset Comparison for Python

PyPI version Python versions License

Recursive subset comparison for complex nested Python data structures. Express relationships like "this nested structure is contained within that one" naturally.

Quick Start

from deepset import deepset

# Set subsets
assert deepset({1, 2}) <= {1, 2, 3}  # True

# Nested structures  
assert deepset({('a', frozenset({2}))}) <= {('a', frozenset({2, 3}))}  # True

# Sequential lists (order matters, gaps allowed)
assert deepset([1, 3]) <= [1, 2, 3, 4]  # True

# Dictionary subsets
assert deepset({'a': 1}) <= {'a': 1, 'b': 2}  # True

# Mixed nested
data1 = {'sets': {frozenset({1, 2})}, 'lists': [[1, 2]]}
data2 = {'sets': {frozenset({1, 2, 3})}, 'lists': [[1, 2, 3]]}
assert deepset(data1) <= data2  # True

Installation

pip install deepset

Comparison Types

Sets: Traditional subset semantics

assert deepset({1, 2}) < {1, 2, 3}  # True (strict subset)
assert deepset({frozenset({1, 2})}) <= {frozenset({1, 2, 3})}  # Recursive

Lists/Tuples: Sequential subset (order preserved, gaps allowed)

assert deepset([1, 3]) <= [1, 2, 3, 4]  # True
assert not deepset([1, 3]) <= [3, 1]    # False (wrong order)

Dictionaries: Key subset + recursive value comparison

assert deepset({'a': 1}) <= {'a': 1, 'b': 2}       # True (extra key)
assert deepset({'a': [1, 2]}) <= {'a': [1, 2, 3]}  # True (recursive)

All Operators: <, <=, ==, >=, > supported

Development

git clone https://github.com/pjkundert/python-deepset.git
cd python-deepset

# Standard development (with user provided Python, package installation)
make install-dev   # Install dev dependencies
make test          # Run tests
make style         # Format code (autopep8, black, isort)
make build         # Build package

# Nix environment (recommended for reproducible builds)
make nix-venv                   # Enter Nix + venv environment
make nix-venv-test              # Run tests in Nix environment
make nix-venv-unit-test_name    # Run specific test class

# Multi-version testing
TARGET=py310 make nix-venv-test # Test with Python 3.10
TARGET=py312 make nix-venv-test # Test with Python 3.12

License

MIT License - Perry Kundert perry@dominionrnd.com

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

deepset-1.0.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

deepset-1.0.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file deepset-1.0.0.tar.gz.

File metadata

  • Download URL: deepset-1.0.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for deepset-1.0.0.tar.gz
Algorithm Hash digest
SHA256 abcfe47480e7b8c5d6ee3838636962ac69f10b44d98024fe28790f093abd1906
MD5 da4ea5bb8c2ba93bf4c8e14b467cd5b2
BLAKE2b-256 dbcea46541cf7d4f4a0192d94457590363a5de25687107d3f21d747ebf336b16

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepset-1.0.0.tar.gz:

Publisher: release.yml on pjkundert/python-deepset

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

File details

Details for the file deepset-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: deepset-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for deepset-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 415d2ae1288e08f3c6b313aa9ea70b161075d53bfce38fff7e63e885a4b296e1
MD5 a94937651474b6fffb50bc6f20589ff4
BLAKE2b-256 33cdf60466c702fbd0d1d25367ec785058f827b7d578ba5d6f6c13078cdbf16e

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepset-1.0.0-py3-none-any.whl:

Publisher: release.yml on pjkundert/python-deepset

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