pydantic
The default data validation library for Python
from datetime import datetime
from typing import Tuple
from pydantic import BaseModel
class Delivery(BaseModel):
timestamp: datetime
dimensions: Tuple[int, int]
m = Delivery(timestamp='2020-01-02T03:04:05Z', dimensions=['10', '20'])
print(repr(m.timestamp))
#> datetime.datetime(2020, 1, 2, 3, 4, 5, tzinfo=TzInfo(UTC))
print(m.dimensions)
#> (10, 20)
Pydantic is the most widely used data validation library, downloaded millions of times a day by thousands of developers all over the world.
Pydantic's success stems from its great developer experience.It's simple to use, even when doing complex things.
FastUI
A new way to build web application UIs defined by declarative Python code.
- Develop responsive apps using React, without writing a single line of JavaScript.
- Concentrate on building magical components that are truly reusable.
from fastapi import HTTPException
from fastui import FastUI, AnyComponent, components as c
from fastui.components.display import DisplayMode, DisplayLookup
from fastui.events import GoToEvent, BackEvent
from my_app import router, fetch_users
@router.get("/users", response_model=FastUI, response_model_exclude_none=True)
async def users_table() -> list[AnyComponent]:
"""Show a table of users"""
users = await fetch_users()
return [
c.Page( # Page provides a basic container for components
components=[
c.Heading(text='Users', level=2), # renders `<h2>Users</h2>`
c.Table(
data=users,
# define two columns for the table
columns=[
# the first is the users, name rendered as a link to their profile
DisplayLookup(field='name', on_click=GoToEvent(url='/user/{id}/')),
# the second is the date of birth, rendered as a date
DisplayLookup(field='dob', mode=DisplayMode.date),
],
),
]
),
]
arq
Fast job queuing and RPC in Python with asyncio and redis.
- Enjoy non-blocking job enqueuing and execution. Multiple jobs can run simultaneously.
- Move fast — asyncio and no forking make Arq around 7x faster than other tools.
import asyncio
from arq import create_pool
from arq.connections import RedisSettings
from httpx import AsyncClient
async def main():
redis = await create_pool(RedisSettings())
for url in ('https://facebook.com', 'https://microsoft.com', 'https://github.com'):
await redis.enqueue_job('download_content', url)
async def download_content(ctx, url):
response = await ctx['session'].get(url)
print(f'{url}: {response.text:.80}...')
return len(response.text)
async def startup(ctx):
ctx['session'] = AsyncClient()
speedate
Fast and simple datetime, date, time and duration parsing for Rust.
- Build with total flexibility. Speedate supports multiple formats.
- Enjoy peace of mind — all relaxations from RFC 3339 are compliant with ISO 8601.
use speedate::{DateTime, Date, Time};
fn main() {
let dt = DateTime::parse_str("2022-01-01T12:13:14Z").unwrap();
assert_eq!(
dt,
DateTime {
date: Date {
year: 2022,
month: 1,
day: 1,
},
time: Time {
hour: 12,
minute: 13,
second: 14,
microsecond: 0,
tz_offset: Some(0),
},
}
);
println!("{}", dt.to_string()); // "2022-01-01T12:13:14Z"
}
jiter
The fast, iterable JSON parser with multiple interfaces.
- Stable and battle tested, jiter is the most downloaded third party JSON parser for Python
- Significantly faster than serde-json in most scenarios
- Supports partial/incomplete JSON parsing, especially useful for LLM output
use jiter::JsonValue;
fn main() {
let json_data = r#"
{
\"name\": \"John Doe\",
\"age\": 43,
\"phones\": [
\"+44 1234567\",
\"+44 2345678\"
]
}"#;
let json_value = JsonValue::parse(json_data.as_bytes(), true).unwrap();
println!("{:#?}", json_value);
}