Metadata-Version: 2.4
Name: structtype
Version: 0.1.0
Summary: Fast Struct type with validation and JSON serialization for Python.
Maintainer-email: Wolfgang Langner <tds333@mailbox.org>
License-Expression: BSD-3-Clause
Project-URL: Homepage, https://github.com/tds333/structtype
Project-URL: Issue Tracker, https://github.com/tds333/structtype/issues
Project-URL: Source, https://github.com/tds333/structtype
Keywords: JSON,schema,serialization,struct,validation
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: WebAssembly :: Emscripten
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# structtype

Fast Struct type with validation + JSON serialization for Python.

- **High performance** — 5-60x faster than dataclasses, attrs, or pydantic for common operations
- **Schema validation** — familiar Python type annotations, enforced at decode time
- **No runtime dependencies** — built on a monolithic C extension based on msgspec
- **Rich type support** — nested Structs, dataclasses, TypedDicts, enums, UUID, Decimal, datetime, and more
- **JSON Schema generation** — auto-generate JSON Schema 2020-12 / OpenAPI 3.1 specs

## Install

```bash
pip install structtype
```

```bash
uv add structtype
```

Requires Python ≥ 3.10.

## Quick Example

```python
from structtype import Struct

class User(Struct):
    name: str
    groups: set[str] = set()
    email: str | None = None

alice = User("alice", groups={"admin", "engineering"})

# Serialize to JSON
alice.struct_dump_json()
# b'{"name":"alice","groups":["admin","engineering"],"email":null}'

# Deserialize and validate
User.struct_validate_json(
    b'{"name":"alice","groups":["admin","engineering"],"email":null}'
)
# User(name='alice', groups={"admin", "engineering"}, email=None)
```

## Documentation

Full documentation is available at **https://tds333.github.io/structtype/**.

## Benchmarks

structtype is as fast as msgspec and about 3-5x faster than pydantic.

## License

New BSD. See the [License File](LICENSE).
The core is based on the work of Jim Crist-Harif from msgspec.
