Skip to main content

iibags

A multiset that behaves the way counting code expects.

Install

pip install iibags

Usage

from iibags import MultiBag

bag = MultiBag(["a", "b", "a"])
bag.count("a")          # 2
bag.count("zzz")        # 0, and no key was created
bag.total()             # 3
bag.unique()            # 2
bag.most_common(1)      # [('a', 2)]

bag.discard("a", 5)     # clamps at zero, removes the key
"a" in bag              # False

Differences from Counter

Case Counter MultiBag
reading a missing key creates it leaves the dict alone
subtracting too much negative counts clamps at zero, drops the key
negative n_count accepted ValueError

Negative counts are the usual source of "why is my inventory -3" bugs, so they are rejected instead of stored.

License

MIT

Metadata

Release files for iibags 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iibags 0.0.2
File Size Uploaded Provenance Actions
iibags-0.0.2.tar.gz 3.2 kB Without provenance Details for iibags-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for iibags 0.0.2
File Interpreter ABI Platform Actions
iibags-0.0.2-py3-none-any.whl Python 3 none any Details for iibags-0.0.2-py3-none-any.whl

Total release size: 6.9 kB

Release files / iibags-0.0.2.tar.gz

Download URL iibags-0.0.2.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1058db61bbdf64ed9086342833653be4586c957885019481b505409b451614fa
BLAKE2b-256 checksum
How to use checksums
c1d38bf4c22cdd549ed92ac99a890ef1c1f525e0e87c17c6176c9f354e735693
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.2-py3-none-any.whl

Download URL iibags-0.0.2-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
719cb9ce555dc3e9ff40d9b8957b8c384dfb15467fd53f2d4b439067dd0dd4dd
BLAKE2b-256 checksum
How to use checksums
ff2d8772fd26790744e5fd87ca89ecd4906af80a570eb0db8eab1f961b0771b2
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.2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page