PicoConf
PicoConf is a tiny, opinionated, lightning fast, and easy to use configuration library for Python. It is designed to be used in small to medium sized projects where a full blown configuration library is overkill.
This project is a Rust port of my NanoConf project, so inherits the usage patterns from that. However, it is roughtly 40x faster!
Installation
uv pip install picoconf
Usage
from picoconf import PicoConf
# or if PicoConf if too long of a name
from picoconf import PC
# Create a new configuration object
config = PicoConf("/path/to/config.pconf")
# Access config values using dictionary-style access
print(config["some_key"])
# Or use dotted attribute access (recommended for cleaner code)
print(config.some_key)
# Both methods work interchangeably
assert config["some_key"] == config.some_key
# Nested values support both access methods too
print(config.database.host) # attribute access
print(config["database"]["host"]) # dictionary access
# Convert to plain Python dict (recursively)
plain_dict = config.to_dict()
# All nested PicoConf objects become regular dicts
Key Normalization
PicoConf is opinionated: all config keys are normalized to lowercase regardless of how they are defined. This applies to keys loaded from .pconf files, kwargs passed to the constructor, and keys introduced via environment variable overrides. It ensures consistent, cross-platform behavior (Windows treats environment variable names as case-insensitive).
# Keys are always stored and accessed in lowercase
config = PC(**{"LOG_LEVEL": "debug", "Database_Host": "localhost"})
print(config.log_level) # "debug"
print(config.database_host) # "localhost"
Always use lowercase when reading config values, even if the source uses uppercase or mixed case.
Configuration File Format
PicoConf uses a simple configuration file format that is easy to read and write. Each File is YAML formatted and contains a single top-level dictionary. Even though the top-level must be a dictionary, you can nest dictionaries and lists as deep as you want. Each config file also must have the .pconf extension. This ensures that PicoConf will only load files that are meant to be configuration files.
key: value
test: 1
overriden: false
things:
- thing1
- thing2
- thing3
top:
v1: 1
middle:
v2: 2
inner:
v3: 3
deep:
v4: 4
If you have multiple config files you want to load into a single config object, you can put them all in the same directory and pass that directory to PicoConf. PicoConf will automatically place sub-files by their filename as an attribute of the parent file. The contents of that file will be accessible as you'd expect under the corresponding filename attribute.
<project root>
conf_dir
|__ cfg1.pconf
|__ cfg2.pconf
|__ cfg3.pconf
# load an entire directory
proj_config = PicoConf("/path/to/conf_dir")
print(proj_config.cfg1.test)
Or you can import additional files or directories from within any config file by using the _import keyword.
# main.pconf
_import:
- /path/to/project/more_config
key: value
test: 1
<project root>
main.pconf
more_config
|__ subcfg1.pconf
|__ subcfg2.pconf
|__ subcfg3.pconf
# loading the main config file will also load the sub-configs
proj_config = PicoConf("/path/to/project/main.pconf")
print(proj_config.more_config.subcfg1.test)
Notice how the directory structure was also maintained in the attribute path. This makes it easier to find the file that a value came from.
Environment Variables
PicoConf supports environment variables either as overrides to existing values or as additions to the loaded config.
Envars are evaluated on a per-file basis, so you can have different envars for different config files.
The way we manage this is by having a special _envar_prefix key in the config file.
Because all keys are normalized to lowercase (see above), env var suffixes are matched case-insensitively by design — MYAPP_LOG_LEVEL and myapp_log_level both map to the log_level config key.
_envar_prefix: myapp
key: value
overrideme: original
export myapp_overrideme=changed
config = PicoConf("/path/to/config.pconf")
print(config.overrideme)
You can also pass complex data structures as JSON strings in environment variables.
export myapp_abc='{"a": 1, "b": 2, "c": 3}'
config = PicoConf("/path/to/config.pconf")
print(config.abc.b)
Overriding Individual Keys in Nested Sections
Because env vars are matched flat against each file's own prefix, there is no built-in delimiter (like __) for drilling into a nested section. The idiomatic way to get per-key env var control over a nested section is to split that section into its own file with its own _envar_prefix, then import it from the parent.
<project root>
main.pconf
connection.pconf
connection.pconf — owns the prefix for its own keys:
_envar_prefix: myapp_connection
host: db.example.com
port: 5432
main.pconf — imports the file so the nesting is preserved:
_envar_prefix: myapp
_import:
- connection.pconf
key: value
config = PicoConf("/path/to/main.pconf")
print(config.connection.host) # db.example.com
Now individual keys in the nested section can be overridden without touching the rest:
export myapp_connection_host=prod-db.example.com
The access path (config.connection.host) stays the same — picoconf nests the imported file under its filename, so the structure is identical to having the values inline in main.pconf.
Converting to Plain Dictionaries
PicoConf objects can be recursively converted to plain Python dictionaries using the to_dict() method. This is useful for serialization, passing to libraries that expect plain dicts, or API responses.
config = PicoConf("/path/to/config.pconf")
# Convert entire config to plain dict
plain = config.to_dict()
# All nested PicoConf objects become regular dicts
assert isinstance(plain, dict)
assert not isinstance(plain, PicoConf)
# Works with deeply nested structures
if "database" in config:
db_dict = config.database.to_dict()
# Can now be serialized to JSON, YAML, etc.
Metadata
Release files for picoconf 0.4.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 |
|---|---|---|---|---|
| picoconf-0.4.0.tar.gz | 17.7 kB | Without provenance | Details for picoconf-0.4.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| picoconf-0.4.0-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details for picoconf-0.4.0-cp311-abi3-win_amd64.whl |
| picoconf-0.4.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ x86-64 | Details for picoconf-0.4.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| picoconf-0.4.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ ARM64 | Details for picoconf-0.4.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| picoconf-0.4.0-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details for picoconf-0.4.0-cp311-abi3-macosx_11_0_arm64.whl |
| picoconf-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl | CPython 3.11 | abi3 | macOS 10.12+ x86-64 | Details for picoconf-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl |
Total release size: 2.0 MB
Release files / picoconf-0.4.0.tar.gz
| Download URL | picoconf-0.4.0.tar.gz |
|---|---|
| Size | 17.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6553437680ac49e3e2c76cffd6662491fac69a61c1782cd95c29642d3a6fab30
|
|
BLAKE2b-256 checksum How to use checksums |
5bbe98388b8aa0d063bff45df6bf62a2843f0f03a12a81f038eabf9b8e03af46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.14.1
|
Release files / picoconf-0.4.0-cp311-abi3-win_amd64.whl
| Download URL | picoconf-0.4.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 301.2 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
96da79b422528689415124c696cae8653154ed88c4a58173033bc67b789942b1
|
|
BLAKE2b-256 checksum How to use checksums |
d6d16746f7f01b0fa266f22395a8f633328ca554b894942ec2e0f20f609b6db5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.14.1
|
Release files / picoconf-0.4.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | picoconf-0.4.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 439.7 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
89b8a10de56330e08fb930e7a23800a53ad9bf987aed30d538ac57c160be5017
|
|
BLAKE2b-256 checksum How to use checksums |
c9663fb53f1ac4f3518ec63a7e4d4e53c5e4791ad70d2cf1d96d34b2c6c01bdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.14.1
|
Release files / picoconf-0.4.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | picoconf-0.4.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 428.7 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
158aeed1157ec31e6ed957c56d90059d49c75c37998f20eafb65f02fabc9736f
|
|
BLAKE2b-256 checksum How to use checksums |
2777122d3e76203bd4c5c8f9b618977a621941083a1d225bd271cec471e474e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.14.1
|
Release files / picoconf-0.4.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | picoconf-0.4.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 392.2 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3aec0462d514ef1ca750d39478473298dbe61f32afa17a3f74c750a1cad92e37
|
|
BLAKE2b-256 checksum How to use checksums |
c49944ea413ae491a8753470d2f49222ca93a7085570a10dc70772cc46d178ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.14.1
|
Release files / picoconf-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | picoconf-0.4.0-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 406.9 kB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
2b4b58329ec760a5a23143ec94b91f2dd4232e6be57d211b6749a34b6920bf7f
|
|
BLAKE2b-256 checksum How to use checksums |
1b3e7b7b49d141b96c4b5e640550156d74ca21ee223ee5bf386818aa566b00b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.14.1
|
Security for picoconf 0.4.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.