⚡ B-FAST (Binary Fast Adaptive Serialization Transfer) - Protocolo de serialização binária de ultra-alta performance, desenvolvido em Rust para o ecossistema Python e TypeScript
Project description
⚡ B-FAST (Binary Fast Adaptive Serialization Transfer)
O B-FAST é um protocolo de serialização binária de ultra-alta performance, desenvolvido em Rust para o ecossistema Python e TypeScript. Ele foi projetado para substituir o JSON em rotas críticas onde latência, uso de CPU e largura de banda são gargalos.
🚀 Por que B-FAST?
- Motor Rust: Serialização nativa sem o overhead do interpretador Python.
- Pydantic Native: Lê atributos de modelos Pydantic diretamente da memória, pulando o lento processo de .model_dump().
- Zero-Copy NumPy: Serializa tensores e arrays numéricos diretamente, atingindo a velocidade máxima de I/O de memória.
- String Interning: Chaves repetidas (como nomes de campos em listas de objetos) são enviadas apenas uma vez.
- Bit-Packing: Inteiros pequenos e booleanos ocupam apenas 4 bits dentro da tag de tipo.
- LZ4 Integrado: Compressão de blocos ultra-veloz para payloads grandes.
📊 Benchmark (Latência Média)
Comparação de serialização de uma lista de 10.000 modelos Pydantic complexos:
| Formato | Tempo (ms) | Tamanho do Payload |
|---|---|---|
| JSON (Standard) | 45.2ms | 1.2 MB |
| Orjson | 12.8ms | 1.1 MB |
| B-FAST | 1.4ms | 240 KB |
📦 Instalação
Backend (Python)
uv add bfast-py
ou
pip install bfast-py
Frontend (TypeScript)
npm install bfast-client
🛠️ Como usar
1. No FastAPI (Integração Direta)
O B-FAST se integra perfeitamente como uma classe de resposta.
from fastapi import FastAPI, Response
from pydantic import BaseModel
import b_fast
class BFastResponse(Response):
media_type = "application/x-bfast"
def __init__(self, content=None, *args, **kwargs):
super().__init__(content, *args, **kwargs)
self.encoder = b_fast.BFast()
def render(self, content) -> bytes:
return self.encoder.encode_packed(content, compress=True)
app = FastAPI()
class User(BaseModel):
id: int
name: str
@app.get("/users", response_class=BFastResponse)
async def get_users():
return [User(id=i, name=f"User {i}") for i in range(1000)]
2. No Frontend (React / Vue / Angular)
import { BFastDecoder } from 'bfast-client';
async function loadData() {
const response = await fetch('/users');
const buffer = await response.arrayBuffer();
// Decodifica e descomprime LZ4 automaticamente
const users = BFastDecoder.decode(buffer);
console.log(users);
}
About B-FAST
"Knowledge is the only wealth that grows when we share it"
B-FAST was born from the belief that high-performance tools should be accessible to everyone. This project represents our commitment to open-source innovation and the sharing of knowledge that drives the developer community forward.
Developed by: marcelomarkus
Philosophy: We believe that by sharing efficient solutions, we collectively raise the bar for what's possible in software development. B-FAST is our contribution to a faster, more efficient web.
📄 Licença
Distribuído sob a licença MIT. Veja LICENSE para mais informações.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bfast_py-1.0.4-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: bfast_py-1.0.4-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 154.6 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
732e54dc3f9fc561a12f4c41401311e20bbdde8f6be4d691b3685b7ede2c383e
|
|
| MD5 |
58b3363f598e3ee076f195d30b7ed367
|
|
| BLAKE2b-256 |
cbe94ec92e4c5e08b75c3d7a5e943792fdd7694f6207ea66e7c1e3a9f1ddee3a
|
File details
Details for the file bfast_py-1.0.4-cp38-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: bfast_py-1.0.4-cp38-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 310.5 kB
- Tags: CPython 3.8+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62a29b396b40e7ca36f93a9aa551fe711348e9441bed36e8d4bc1fee483a7a07
|
|
| MD5 |
ee2dd8538d8a85cde8e8f9d5cda0a169
|
|
| BLAKE2b-256 |
424b2d97562afb21640d936b343bc36b76d611e3912abe908a11325588c70f67
|
File details
Details for the file bfast_py-1.0.4-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: bfast_py-1.0.4-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 264.4 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bbb0c570d65329749c2dcd4fc2eef44f071bdf03856ed92feeb12c001bad0d0
|
|
| MD5 |
bbe7deb36ee204dba5b7cfa9dea1f1db
|
|
| BLAKE2b-256 |
1f7ff8bc5cfa892ab2ea16afb48d7696dbdb5758da59b3fa5de4b4876968823c
|