iibags
English | 中文
带显式算术的计数多重集合。
安装
pip install iibags
用法
from iibags import MultiBag
bag = MultiBag(["a", "b", "a"])
bag.count("a") # 2
bag.count("zzz") # 0,且没有创建键
bag.total() # 3
bag.unique() # 2
bag.most_common(1) # [('a', 2)]
bag.discard("a", 5) # 归零并删除键
"a" in bag # False
说明
与 Counter 的差别:读一个不存在的键不会创建它;扣减超额时归零并删除键,不留负数;n_count 传负数直接抛 ValueError——负计数是「库存怎么变成 -3」的常见根源。
许可证
MIT
English
A counting multiset with explicit arithmetic.
Install
pip install iibags
Usage
from iibags import MultiBag
bag = MultiBag(["a", "b", "a"])
bag.count("a") # 2
bag.count("zzz") # 0,且没有创建键
bag.total() # 3
bag.unique() # 2
bag.most_common(1) # [('a', 2)]
bag.discard("a", 5) # 归零并删除键
"a" in bag # False
Notes
Unlike Counter: reading a missing key does not create it, over-subtracting clamps to zero and drops the key, and a negative n_count raises ValueError. Negative counts are the usual source of "why is my inventory -3" bugs.
License
MIT
Metadata
Release files for iibags 0.0.4
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 | Actions |
|---|---|---|---|---|
| iibags-0.0.4.tar.gz | 3.6 kB | Without provenance | Details for iibags-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iibags-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for iibags-0.0.4-py3-none-any.whl |
Total release size: 7.5 kB
Release files / iibags-0.0.4.tar.gz
| Download URL | iibags-0.0.4.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d113648a1084b26089b7394c3ba41dc45f370f9ac47a7d44e1bbbd50ea8b2470
|
|
BLAKE2b-256 checksum How to use checksums |
2c9db64b101c1931d8cc13a292e688c6d16afdbd25c6c008e3b58c8c7e1df998
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / iibags-0.0.4-py3-none-any.whl
| Download URL | iibags-0.0.4-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e180a5894f91a92bca9e1824c78ba47aef6ad9a20f6aeb2a1845338d55f98e46
|
|
BLAKE2b-256 checksum How to use checksums |
ed383f4898d2d6b870feb825cb216d79de3df6144bd67e72e56100f1e69aec79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for iibags 0.0.4
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.