Type Enforced is a zero-dependency Python library (plus an automatic C++ build with fallback if you have a compiler) for high-throughput runtime type validation. It verifies standard and nested type annotations on callables very fast.
For a simple int validation, it adds ~10 nanoseconds of overhead (less than a frame call) by manipulating the code via AST. Other performance gains if using the C++ variant include loop unrolling for complete nested checks and much more.
On a practical level, it speeds up development for humans and AI agents alike.
It's ~15x faster than beartype for sampled validation
It's ~20x faster than pydantic for full validation
Benchmarks: https://github.com/connor-makowski/type_enforced/blob/main/b...
Example:
```python
from type_enforced import Enforcer
@Enforcer
def process_point(x: float) -> dict[str,float|int]:
return {"point": x}
process_point(1.5)
process_point("invalid") # Raises error
```