Fond
Foundation for Cooking, Foundation for Life.
Experimental: This package is under active development. APIs may change without notice.
A C++26 header-only library and the Python package built on it: the building blocks we kept rewriting for every project, in one self-contained place. The same C++ sits under both sides, so the headers you vendor or compile against are the ones behind fond's Python tools: a file lock, a TOML table or a MessagePack blob behaves the same from either language. External dependencies are kept to a minimum on purpose (on Python, pydantic and tzdata), so one install brings the whole toolbox.
Requirements
- A C++26 compiler: GCC 16 (primary, and it brings C++26 reflection with
-freflection), or Clang + libc++ as the fallback - Python 3.14+
Optional C++ integrations (CPython, CTRE, glm, Lua/sol2, SDL3, ...) are detected with __has_include and
switch on only when present.
Three ways to use fond
None of these is the "real" one.
1. Vendored C++
Carry fond as a git submodule and link the one fond::fond target:
set(FOND_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/vendor/fond" CACHE PATH "fond checkout")
include("${FOND_ROOT}/cmake/FondTarget.cmake")
target_link_libraries(app PRIVATE fond::fond)
FOND_ROOT is a cache variable, so when fond is vendored at several layers, the top-level checkout
wins and the build gets exactly one fond.
2. Build-time, for Python extensions
The pybind11 pattern: your build pulls the headers in, the code compiles into your own wheel, and your users never install fond.
[build-system]
requires = ["scikit-build-core", "fond>=0.4.7"]
build-backend = "scikit_build_core.build"
execute_process(COMMAND "${Python_EXECUTABLE}" -c "import fond; print(fond.get_cmake_dir())"
OUTPUT_VARIABLE FOND_CMAKE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY)
include("${FOND_CMAKE_DIR}/FondTarget.cmake")
For the bindings themselves, fond/py_tools/ wraps the raw CPython API in typed handles (Module,
Dict, Tuple, Iterator, Class<>, ...) with error guards, GIL helpers and type-slot macros. No
pybind11 needed.
#include <fond/macros/strong_enum.hpp>
#include <fond/py_tools/handles/module.hpp>
#include <fond/py_tools/handles/str.hpp>
#include <fond/py_tools/int_enum.hpp>
#include <fond/py_tools/utils/err.hpp>
#include <fond/strings/ops.hpp>
STRONG_ENUM_STR(Mode, uint8_t, Debug, Release);
using namespace Fond::Py;
// shout(text: str) -> str. python_error() or any C++ exception becomes a Python exception at the boundary.
static PyObject* shout(PyObject*, PyObject* arg) {
return guarded<"shout failed">([&]() -> PyObject* {
if (!PyUnicode_Check(arg)) {
PyErr_SetString(PyExc_TypeError, "shout() takes a str");
python_error();
}
return String::From(Fond::Str::upper(String::borrow(arg).view())).release();
});
}
static PyMethodDef demo_methods[] = {{"shout", shout, METH_O, "Upper-case a string."}, {}};
static PyModuleDef demo_module = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "demo",
.m_doc = "fond's README example.",
.m_size = -1,
.m_methods = demo_methods,
.m_slots = nullptr,
.m_traverse = nullptr,
.m_clear = nullptr,
.m_free = nullptr,
};
PyMODINIT_FUNC PyInit_demo(void) {
Module module = Module::Create(&demo_module);
if (!module || !module.Add("Mode", make_int_enum<Mode>("Mode", "demo"))) return nullptr; // the C++ enum as an IntEnum
return module.release();
}
demo.shout("hi") gives "HI", demo.shout(3) raises TypeError, and list(demo.Mode) is
[<Mode.Debug: 0>, <Mode.Release: 1>], built from the C++ names so the two can't drift apart.
3. The Python package
uv add fond # extras: fond[profile] (rich reports), fond[db] (SQLAlchemy)
from fond import X is the public, stable surface. Every other import path is internal and may move.
Python tools
from fond import Struct, field, MaybeIDK, lru_cache, now
class Point(Struct, frozen=True):
x: float
y: float = 0.0
tags: list[str] = field(default_factory=list)
p = Point(1.5) # __init__, __eq__, __repr__ written for you; slotted
port = MaybeIDK().value_or(8080) # std::optional in Python: empty is nullopt, and None is a value
@lru_cache(maxsize=256) # functools-style; LRUCache is the same cache as a plain mapping
def area(w: int, h: int) -> int: return w * h
stamp = now() # EpochTimestamp: an int of epoch time that knows its precision
- Records:
Struct/@struct(slotted, frozen, lazy fields, converters),to_dict,is_built - Optionals:
MaybeIDK, thestd::optionalAPI (value_or,transform,and_then, ...) - Collections:
OrderedSet,FrozenDict/freeze,LRUCache/lru_cache/cache/once,SimpooQueue, sentinels - Files:
FileLock(shared/exclusive, self-cleaning lock files),atomic_write,Pathy,stat_info,.gitignorematching - TOML: Python bindings for toml++:
toml_loads/toml_load_fileandtoml_dumps/toml_dump_file, so you can write TOML too (the stdlib'stomllibonly reads) - MessagePack:
msgpack_pack/msgpack_unpack, to and from bytes or files in one call - Time:
EpochTimestamp, durations to and from"1h 30m", timers - Config:
SettingsManager(one JSON file),ConfigManager(TOML layers + env overrides into Pydantic) - Events:
FSM,Signal,Bus - Patterns:
SingletonBase/SingletonWrap(lazy, thread-safe singletons),MISSING/NOTSET - Numbers: fixed-width ints (
int8_t...),float32_t,i8...u64wrap/clamp,Dollars,Vec2/Vec3/Vec4 - Profiling:
fond.tools.utils.profiler(benchmark, compare, import timing) - CLIs:
generate-macros,amalgamate(merge headers into one),fond-dev
Experimental
These bend Python on purpose. They work, and they may change shape.
Namespaces: several named groups in one file, none of them types.
from fond import namespace
class Angle(metaclass=namespace):
PI = 3.141592653589793
def radians(degrees: float) -> float:
return degrees * Angle.PI / 180
pycub: C-style # if blocks, resolved before Python tokenizes the file (fond-dev pycub install once).
# -*- coding: pycub -*-
# if __APPLE__
CACHE = "~/Library/Caches/app"
# elif _WIN32
CACHE = "%LOCALAPPDATA%/app"
# else
CACHE = "~/.cache/app"
# endif
Privates: C++ private, enforced by rewriting the class's bytecode. Anything imported from
fond.tools.experiments is considered unstable at this time.
from fond.tools.experiments.privates import PrivateMeta, Private
class Account(metaclass=PrivateMeta):
balance: Private[int]
def __init__(self) -> None:
self.balance = 0 # fine inside the class; Account().balance doesn't exist outside
What's inside the C++
# server.toml
host = "example.com"
port = 443
mode = "Release"
#include <fond/macros/strong_enum.hpp>
#include <fond/toml/define.hpp>
#include <fond/toml/reader.hpp>
#include <print>
STRONG_ENUM_STR(Mode, uint8_t, Debug, Release); // names, from_string(), all_names(), no hand-written tables
struct ServerConfig {
std::string host = "localhost";
int port = 8080;
std::string mode = "Debug";
TOML_DEFINE(ServerConfig, host, port, mode) // toml_unpack() / toml_pack(), field by field
};
int main() {
auto cfg = ServerConfig::toml_unpack(Fond::Toml::Reader::parse_file("server.toml").as_table());
Mode mode = Mode::from_string(cfg.mode).value_or(Mode::Debug);
std::println("{}:{} in {}", cfg.host, cfg.port, mode.name()); // example.com:443 in Release
}
- collections: policy-based Set/Map (ordered, frozen), Arena, Pool, SlotMap, Deque, BitFlag, Trie, LRU caches, ring buffers, sparse sets
- bytes / msgpack / toml / lua: endian-aware binary readers and writers, a toml++ wrapper, plus
*_DEFINEmacros for struct serialization - py_tools: typed CPython handles, the code behind fond's own extensions
- logger:
BasicLogger<Sinks...>with sinks composed at compile time - argparse: Python-style argument parsing
- config: ConfigManager with TOML and env-var overrides, KeyStore
- strings / cli: string helpers, UTF-8, fuzzy matching, a Rich-style console
- math: constexpr Vec/Mat4/quaternion, compile-time math, money, glm interop
- mixins:
Selfaboo(CRTPself(), plus the type's own name, its base's and its lineage at compile time),SingletonBase(lazy, thread-safeGet()/Reset()),Hashable(aTypeIDthat matches across clang, GCC and MSVC),IDMixin(incrementing IDs per tag type) - types: UUID, reflection and type-name helpers
- time / concurrency / events / hashlib / files: timers and epochs, thread pool and queues, events and FSM, SHA-256/CRC64/SipHash, file locks, atomic writes, walking and watching
License
Mozilla Public License 2.0. Use fond in anything, commercial or not; if you ship changes to fond's own files, share those changes.
Metadata
Release files for fond 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 15.5 MB
Release files / fond-0.5.0-cp315-cp315-win_amd64.whl
| Download URL | fond-0.5.0-cp315-cp315-win_amd64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.15 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
37d92297d52e0937dbf58a5cc0975065797bf44ea866aa8c8f6dc676bdc3a059
|
|
BLAKE2b-256 checksum How to use checksums |
b8421e4434505cccc0090f418aeed45703765f412d744561470f070c566aada5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / fond-0.5.0-cp315-cp315-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
| Download URL | fond-0.5.0-cp315-cp315-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.15 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
6bf2cd5f6a7be5f5bbda83f2efbf098dadcf9b7791e8acf02c89f4ba36a800ae
|
|
BLAKE2b-256 checksum How to use checksums |
392f18a1df6c51459fe81ee83f9ec2919a8755d2a6e5c564cbecc8c16f67bd5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / fond-0.5.0-cp315-cp315-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
| Download URL | fond-0.5.0-cp315-cp315-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.15 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
ed6394bd421e67806b12f10d977a395d720f79c53721c40f25b85fe3dd745bc2
|
|
BLAKE2b-256 checksum How to use checksums |
633e20ee5ae5280996176ce7f33b8ab5769212dfd0035df9219a2d1bf189e742
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / fond-0.5.0-cp315-cp315-macosx_15_0_arm64.whl
| Download URL | fond-0.5.0-cp315-cp315-macosx_15_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.15 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d0b229a87f841a78cb215ebab615330ac43efe8df3311a059c96e2c9629f8bb0
|
|
BLAKE2b-256 checksum How to use checksums |
8ac34036013cf325a35fbdec95eadb63a31735a7cf04666d3a7e5b4c6c4a4443
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / fond-0.5.0-cp314-cp314-win_amd64.whl
| Download URL | fond-0.5.0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ce6c9357527d525da326a3cda0964464a3710eb707f6833a9b2b3a154bc11a32
|
|
BLAKE2b-256 checksum How to use checksums |
c9d9c5f42185ad8ba7fd7ba4b8e1ac6c1bcd20b0f6c7cf37b86c1cb0b23747eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / fond-0.5.0-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
| Download URL | fond-0.5.0-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.14 Linux glibc 2.26+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
d067d2d1c12eec1f30f129aba7bc0e8775c7a236f73a79c96474be18980596f9
|
|
BLAKE2b-256 checksum How to use checksums |
c965d258d87df7fa0627386686ba9921691b5d6ff5b482da610d058a16d69f4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / fond-0.5.0-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
| Download URL | fond-0.5.0-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.14 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
e70048158100ce09e6fb58bebbb6f790b0e48e50aad3aeb074f5aaba569e4a53
|
|
BLAKE2b-256 checksum How to use checksums |
3380b8e2c4ccea2698fad10e05cf504fdd551ec3c546839a60075d2577ff0e62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / fond-0.5.0-cp314-cp314-macosx_15_0_arm64.whl
| Download URL | fond-0.5.0-cp314-cp314-macosx_15_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.14 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ade7931dd6191f81aba5c24646fe43ca1b16c296bc7b000d9a671c8a6077cd4b
|
|
BLAKE2b-256 checksum How to use checksums |
6482dc36553a35bbdac3e1003e2159be33fecbbff7aeda4a53bacd4a2aec3e9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for fond 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.
Full provenance
All 8 files in this release have been uploaded with provenance metadata.
Attestation for fond-0.5.0-cp315-cp315-win_amd64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA 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.