fastval 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ include fastval/*.pyx
2
+ include fastval/*.py
fastval-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastval
3
+ Version: 0.1.0
4
+ Requires-Dist: orjson
5
+ Dynamic: requires-dist
@@ -0,0 +1,75 @@
1
+ # FastVal
2
+
3
+ Ultra-fast Cython-based data validation library for Python, optimized for FastAPI. A faster alternative to Pydantic.
4
+
5
+ ## Features
6
+
7
+ - Fast validation using Cython
8
+ - Nested model support
9
+ - Optional fields with defaults
10
+ - JSON serialization with orjson
11
+ - Drop-in compatible with FastAPI
12
+ - Pydantic-style annotations
13
+
14
+ ## Installation
15
+
16
+ Clone the repo and build:
17
+
18
+ ```bash
19
+ git clone https://github.com/youruser/fastval.git
20
+ cd fastval
21
+ pip install -e .
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ Define models with annotations, just like Pydantic:
27
+
28
+ ```python
29
+ from fastval import BaseModel
30
+ from typing import List
31
+
32
+ class User(BaseModel):
33
+ name: str
34
+ age: int = 25
35
+ email: str
36
+
37
+ class Post(BaseModel):
38
+ title: str
39
+ content: str
40
+ author: User
41
+ tags: List[str] = []
42
+
43
+ # Validate data
44
+ user = User({'name': 'John', 'email': 'john@example.com'})
45
+ print(user.dict()) # {'name': 'John', 'age': 25, 'email': 'john@example.com'}
46
+ print(user.json()) # JSON string
47
+ ```
48
+
49
+ For FastAPI:
50
+
51
+ ```python
52
+ from fastapi import FastAPI
53
+
54
+ app = FastAPI()
55
+
56
+ @app.post("/users")
57
+ async def create_user(payload: dict):
58
+ user = User(payload)
59
+ return user.dict()
60
+ ```
61
+
62
+ ## Benchmarks
63
+
64
+ FastVal outperforms Pydantic in validation and JSON serialization:
65
+
66
+ - **10,000 users validation**: FastVal 2.61x faster (0.0042s vs 0.0109s)
67
+ - **JSON serialization**: FastVal 2.99x faster (0.0023s vs 0.0068s)
68
+ - **Nested models (1,000 posts)**: FastVal 1.44x faster (0.0009s vs 0.0013s)
69
+ - **Large payloads (100k users)**: FastVal 2.21x faster (0.0647s vs 0.1429s)
70
+
71
+ Run `python benchmark.py` to see live results.
72
+
73
+ ## Tests
74
+
75
+ Run `pytest tests/`
@@ -0,0 +1,4 @@
1
+ from .models import BaseModel
2
+ from .exceptions import ValidationError
3
+
4
+ __all__ = ['BaseModel', 'ValidationError']
@@ -0,0 +1,2 @@
1
+ class ValidationError(ValueError):
2
+ pass