This is the final release to gloss-colletion.
Find future updates at https://pypi.org/project/gloss/
gloss-collection
Gloss (short for glossary) is a different kind of dictionary. All values also automatically become keys and so can be looked up in the Gloss to find its corresponding 'key'. This makes it easy to lookup and maintain one-to-one relationships such as a label to a certain magnitude.
As both the key and value are gettable items from the Gloss and
are indistinguishable once added, term is the preferred name
for items in a Gloss, and a term pair is the 1-1 mapping each
term belongs to.
Gloss is a MutableMapping and supports all the same methods
that dict does.
Examples
from gloss import Gloss
example = Gloss()
example["stdin"] = 0
example.update({"stdout": 1, "stderr": 2})
print(example)
#Gloss({"stdin": 0, "stdout": 1, "stderr": 2})
print(example[1], "goes to" example["stderr"])
#stdout goes to 2
example[3] = "config.toml"
example[1] = "shell pipe"
print(example)
#Gloss({"stdin": 0, "stderr": 2, "config.toml": 3, "shell pipe": 1})
print([fd_or_desc for fd_or_desc in example])
#["stdin", "stderr", "config.toml", "shell pipe", 0, 1, 2 , 3]
Shouldn't I just use an enum?
Great thought! You can, and often should, use an Enum for these sorts of relationsips. Besides being built in to Python, Enums are probably faster and more space efficient. However, some limitations of Enums solved by Gloss are:
- enum members are static. They are defined all at once in the class and their values cannot change. A Gloss on the other hand can be added to, altered, even have members deleted or popped, all at runtime
- Accessing Enum member namess and their values are differnt operations. Looking up a member by name is done with either dot dereference or getitem; looking up a member by value is done with a call. With a Gloss you don't have to know which side of the mapping your key is on (if there even is a distinction to the mapping), it is all done by getitem
- One side of an enum mapping must be a string. Because member names are attributes they must follow Python identifier naming rules. In a Gloss, all keys may be any hashable object
Shouldn't I just use a dict?
While the classic dict solves some of limitations of using an Enum, primarily being mutable at runtime, looking up any value is O(n) and therefore so is updating, deleting, poping, etc that value. In a Gloss searching for any value is O(1) time, and updating that value (for example chaning the key it maps to) can be done in a single operation.
Metadata
Release files for gloss-collection 1.2.1
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 | |
|---|---|---|---|---|
| gloss-collection-1.2.1.tar.gz | 4.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gloss_collection-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / gloss-collection-1.2.1.tar.gz
| Download URL | gloss-collection-1.2.1.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0bbd6e76fad41c0438d2251705aab735efb0f82afca898767885623e7803c5e
|
|
BLAKE2b-256 checksum How to use checksums |
327f72080e9f2e52b840dbc8b8f9b52292c8b0377515e16885354e16595c5825
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.3
|
Release files / gloss_collection-1.2.1-py3-none-any.whl
| Download URL | gloss_collection-1.2.1-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0a35cea93455750ebd992a5801b46ef56d52f2e5273ada708fd8431b09bab8e5
|
|
BLAKE2b-256 checksum How to use checksums |
9b0221fb5b2ea041e2023efe99545f8b4b2c2e89844d38ff8926661c353e07f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.3
|
Security for gloss-collection 1.2.1
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.