222
English | 中文
两个字典的结构差异,嵌套键以点号路径呈现。
安装
pip install 222
用法
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
English
Structural diff between two dicts, nested keys included.
Install
pip install 222
Usage
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
Metadata
Release files for 222 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| 222-0.0.3.tar.gz | 3.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 222-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.3 kB
Release files / 222-0.0.3.tar.gz
| Download URL | 222-0.0.3.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ccf02ba0f39fce013ae1c1d37841419427ca7bae444eb2eaa59f80e1a63f9c60
|
|
BLAKE2b-256 checksum How to use checksums |
abd171f310c3a9b3c4b2f0523ea5f5c928af3c7ba1900adaec5710be2482b7a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / 222-0.0.3-py3-none-any.whl
| Download URL | 222-0.0.3-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37d64898710dbf1819d506710639f738311700c5b431b45bb3ca14bcea6542ce
|
|
BLAKE2b-256 checksum How to use checksums |
5a6ca9d46f72d81d6bb927b77ee6124fb0dc7374159a9afe5665acc27aab059c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for 222 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.