Broadcast Dictionary
Python dictionary with broadcast support.
Behaves like a regular dictionary.
Allows to apply operations to all its values at once. Whithout loops, whithout dict comprehension.
Installation
pip install bcdict
Usage
from bcdict import BCDict
>>> d = BCDict({"a": "hello", "b": "world!"})
>>> d
{'a': 'hello', 'b': 'world!'}
Regular element access:
>>> d['a']
'hello'
Regular element assignments
>>> d['a'] = "Hello"
>>> d
{'a': 'Hello', 'b': 'world!'}
Calling functions:
>>> d.upper()
{'a': 'HELLO', 'b': 'WORLD!'}
Slicing:
>>> d[1:3]
{'a': 'el', 'b': 'or'}
Applying functions:
>>> d.pipe(len)
{'a': 5, 'b': 6}
When there is a conflict between an attribute in the values and an attribute in
BCDict, use the attribute accessor explicitly:
>>> d.a.upper()
{'a': 'HELLO', 'b': 'WORLD!'}
Slicing with conflicting keys:
>>> n = BCDict({1:"hello", 2: "world"})
>>> n[1]
'hello'
>>> # Using the attribute accessor:
>>> n.a[1]
{1: 'e', 2: 'o'}
Next steps
See the introduction notebook and other examples.
Also check out the full documentation on bcdict.readthedocs.io.
Changelog
v0.5.0
- feature: broadcast attribute and item assignment
- fix: broadcast slicing with
.aaccessor
v0.4.3
- fix: unpickling causes recursion error
v0.4.2
- docs: improve the documenation
v0.4.1
- fix: sphinxcontrib-mermaid gets installed as default dependency, should be dev dependency
v0.4.0
- new functions
eq()andne()for equality/inequality with broadcast support
v0.3.0
- new functions in
bcdictpackage:apply()broadcast()broadcast_arg()broadcast_kwarg()
- docs: write some documentation and host it on readthedocs
v0.2.0
- remove
item()function. Use.a[]instead.
v0.1.0
- initial release
Original repository: https://github.com/mariushelf/bcdict
Author: Marius Helf (helfsmarius@gmail.com)
Metadata
Release files for bcdict 0.5.0
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 |
|---|---|---|---|---|
| bcdict-0.5.0.tar.gz | 8.2 kB | Without provenance | Details for bcdict-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bcdict-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for bcdict-0.5.0-py3-none-any.whl |
Total release size: 15.4 kB
Release files / bcdict-0.5.0.tar.gz
| Download URL | bcdict-0.5.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
519eec003d94ce77f009cca2f34648cda8be2b6892a1677e29b53f4172f1adb2
|
|
BLAKE2b-256 checksum How to use checksums |
42d32b4bd8bf34f7e4448f38d1c997dcca2b8fafdcca796242dc55f9bc0f49e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.13
|
Release files / bcdict-0.5.0-py3-none-any.whl
| Download URL | bcdict-0.5.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
376d2fe3e81c2fae7864ad394262403879622bdb57e16860139f0fd4f1586cbc
|
|
BLAKE2b-256 checksum How to use checksums |
88905bb1ee38df506ad9a52f452aaa09bf37b3d3c42e7c9baec3241c9bf55543
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.13
|
Security for bcdict 0.5.0
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.