keyso
keyso is a small Python library for expanding dictionary-based configuration
spaces.
The input format is plain Python dictionaries. The public data model is not the syntax tree. The public model consists of semantic configuration objects:
ConfigurationTypeConfigurationConfigurationSpace
Syntax constructs such as _literal, _nested, _product, _union,
_intersection, and _difference are handled by the dictionary front end. They
are not exported into the top-level keyso namespace as semantic data types.
When users want to construct these dictionaries programmatically, they can use
the separate keyso.construct namespace.
Basic usage
import keyso
space = keyso.from_dictionary(
{
"_product": [
{"compiler": ["gcc", "clang"]},
{"optimization": ["O2", "O3"]},
]
}
)
assert space.configuration_type.to_set() == {"compiler", "optimization"}
configs = space.to_dicts()
configs is:
[
{"compiler": "clang", "optimization": "O2"},
{"compiler": "clang", "optimization": "O3"},
{"compiler": "gcc", "optimization": "O2"},
{"compiler": "gcc", "optimization": "O3"},
]
The exact ordering is deterministic but should not be used as part of the mathematical meaning of a configuration space.
Public API
Top-level semantic API:
keyso.ConfigurationType
keyso.Configuration
keyso.ConfigurationSpace
keyso.from_dictionary(dictionary) -> ConfigurationSpace
keyso.expand(dictionary) -> list[dict[str, object]]
keyso.normalize(dictionary) -> {"_set": list[dict[str, object]]}
Constructor namespace for programmatically building dictionary inputs:
keyso.construct.Literal
keyso.construct.Nested
keyso.construct.Set
keyso.construct.Product
keyso.construct.Union
keyso.construct.Intersection
keyso.construct.Difference
keyso.construct.evaluate(...)
These names intentionally live under keyso.construct, not directly under
keyso.
Constructor namespace
For code that wants to build keyso dictionaries instead of writing raw dictionary
literals, use keyso.construct.
import keyso
space = keyso.construct.evaluate(
keyso.construct.Product(
{"compiler": ["gcc", "clang"]},
{"optimization": ["O2", "O3"]},
)
)
assert space.to_dicts() == [
{"compiler": "clang", "optimization": "O2"},
{"compiler": "clang", "optimization": "O3"},
{"compiler": "gcc", "optimization": "O2"},
{"compiler": "gcc", "optimization": "O3"},
]
The constructor objects can also be converted to plain dictionaries:
dictionary = keyso.construct.Product(
{"compiler": ["gcc", "clang"]},
{"optimization": ["O2", "O3"]},
).to_dictionary()
assert dictionary == {
"_product": [
{"compiler": ["gcc", "clang"]},
{"optimization": ["O2", "O3"]},
]
}
Lower-case helper functions return dictionaries directly:
dictionary = keyso.construct.product(
{"compiler": ["gcc", "clang"]},
{"optimization": ["O2"]},
)
configs = keyso.expand(dictionary)
For nested and literal values:
dictionary = {
"build": keyso.construct.nested(
keyso.construct.Product(
{"compiler": ["gcc", "clang"]},
{"params": keyso.construct.literal({"flags": ["-O2", "-Wall"]})},
)
)
}
Combining keys
Multiple independent keys must be combined explicitly with _product.
Valid:
{
"_product": [
{"compiler": ["gcc", "clang"]},
{"optimization": ["O2", "O3"]},
]
}
Invalid:
{
"compiler": ["gcc", "clang"],
"optimization": ["O2", "O3"],
}
The second form is rejected because it would be an implicit product.
Nested dictionaries
Use _nested when the value of a key should be produced by an independent
keyso dictionary.
keyso.expand(
{
"build": {
"_nested": {
"_product": [
{"compiler": ["gcc", "clang"]},
{"optimization": ["O2", "O3"]},
]
}
}
}
)
produces:
[
{"build": {"compiler": "clang", "optimization": "O2"}},
{"build": {"compiler": "clang", "optimization": "O3"}},
{"build": {"compiler": "gcc", "optimization": "O2"}},
{"build": {"compiler": "gcc", "optimization": "O3"}},
]
Use _literal when a dictionary is data and should not be interpreted as keyso:
keyso.expand(
{
"params": {
"_literal": {
"nx": 128,
"ny": 128,
}
}
}
)
Normalization
normalize() returns the normalized _set representation:
keyso.normalize({"compiler": ["gcc", "clang"]})
returns:
{
"_set": [
{"compiler": "clang"},
{"compiler": "gcc"},
]
}
Development
Run tests with:
hatch run tests:test
or directly:
PYTHONPATH=src pytest
Metadata
Release files for keyso 0.2.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 |
|---|---|---|---|---|
| keyso-0.2.0.tar.gz | 111.1 kB | Without provenance | Details for keyso-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keyso-0.2.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for keyso-0.2.0-py2.py3-none-any.whl |
Total release size: 125.8 kB
Release files / keyso-0.2.0.tar.gz
| Download URL | keyso-0.2.0.tar.gz |
|---|---|
| Size | 111.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ed780cb1e36e76227e6da9faf58d2fae1da9a36d673250f919934a9c1797eec
|
|
BLAKE2b-256 checksum How to use checksums |
8743ff63005ae78f60d3859c3769e1c7b103cd4f78518ad131b0862267c9da51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.18.1 {"ci":null,"cpu":"x86_64","distro":{"libc":{"lib":"glibc","version":"2.44"},"name":"Arch Linux"},"implementation":{"name":"CPython","version":"3.14.8"},"installer":{"name":"hatch","version":"1.18.1"},"openssl_version":"OpenSSL 3.6.5 29 Sep 2026","python":"3.14.8","system":{"name":"Linux","release":"6.18.56-1-lts"}} HTTPX2/2.13.1
|
Release files / keyso-0.2.0-py2.py3-none-any.whl
| Download URL | keyso-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
4177d8dc659d2b0ee4addad6916b50ac15c45627c8cb4312deaa19b411b19338
|
|
BLAKE2b-256 checksum How to use checksums |
ccff2ed5c7984a4b262405429496fe9e087765b860535e705d54b03232a1e159
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.18.1 {"ci":null,"cpu":"x86_64","distro":{"libc":{"lib":"glibc","version":"2.44"},"name":"Arch Linux"},"implementation":{"name":"CPython","version":"3.14.8"},"installer":{"name":"hatch","version":"1.18.1"},"openssl_version":"OpenSSL 3.6.5 29 Sep 2026","python":"3.14.8","system":{"name":"Linux","release":"6.18.56-1-lts"}} HTTPX2/2.13.1
|
Security for keyso 0.2.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.