Metadata-Version: 2.5
Name: 222
Version: 0.0.3
Summary: Structural diff between two dicts, nested keys included.
Project-URL: Homepage, https://pypi.org/project/222/
Author-email: lqxnjk <lqxnjk@qq.com>
License: MIT
License-File: LICENSE
Keywords: changes,compare,dict,diff,nested
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# 222

[English](#english) | 中文

两个字典的结构差异，嵌套键以点号路径呈现。

## 安装

```console
pip install 222
```

## 用法

```python
from p222 import apply_diff, dict_diff

left = {"db": {"port": 5432, "host": "a"}, "tags": ["x"], "gone": 1}
right = {"db": {"port": 6543, "host": "a"}, "tags": ["y"], "new": 2}

dict_diff(left, right)
# {'db.port': ('changed', 5432, 6543),
#  'gone':    ('removed', 1, None),
#  'new':     ('added', None, 2),
#  'tags':    ('changed', ['x'], ['y'])}

apply_diff(left, dict_diff(left, right)) == right   # True
```

## 说明

包名以数字开头，导入名是 `p222`。嵌套 dict 递归比较，变化落在 `db.pool.size` 这样的路径上，而不是整棵子树被替换。`apply_diff` 可反向应用，满足 `apply_diff(left, dict_diff(left, right)) == right`。

## 许可证

MIT

---

<a id="english"></a>
## English

Structural diff between two dicts, nested keys included.

## Install

```console
pip install 222
```

## Usage

```python
from p222 import apply_diff, dict_diff

left = {"db": {"port": 5432, "host": "a"}, "tags": ["x"], "gone": 1}
right = {"db": {"port": 6543, "host": "a"}, "tags": ["y"], "new": 2}

dict_diff(left, right)
# {'db.port': ('changed', 5432, 6543),
#  'gone':    ('removed', 1, None),
#  'new':     ('added', None, 2),
#  'tags':    ('changed', ['x'], ['y'])}

apply_diff(left, dict_diff(left, right)) == right   # True
```

## Notes

The import name is `p222` because the distribution starts with a digit. Nested dicts are compared recursively and reported as dotted paths such as `db.pool.size`. `apply_diff` reverses the diff, so the round trip is exact.

## License

MIT
