/opensource

赋能Python 社区

我们的开源软件包是为 Python 和 Rust 社区构建的,并采用 MIT 许可证 — 并且将永远如此。

pydantic

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 是使用最广泛的数据验证库, 每天被全球数千名开发人员下载数百万次。

Pydantic 的成功源于其出色的开发者体验。即使在执行复杂操作时,它也很容易使用。

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); }

Pydantic 开源基金

长期以来,开源生态系统一直被视为理所当然。我们很自豪能成为改变这一现状的运动的一部分。更多关于 Pydantic 开源基金计划。

Pydantic 很自豪成为 开源承诺