Skip to main content

⚡ 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 @b-fast/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 '@b-fast/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bfast_py-1.0.3-cp38-abi3-win_amd64.whl (154.6 kB view details)

Uploaded CPython 3.8+Windows x86-64

bfast_py-1.0.3-cp38-abi3-manylinux_2_34_x86_64.whl (310.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.34+ x86-64

bfast_py-1.0.3-cp38-abi3-macosx_11_0_arm64.whl (264.4 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file bfast_py-1.0.3-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: bfast_py-1.0.3-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

Hashes for bfast_py-1.0.3-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f1317cd8776130be1c485ba95f45b765253c85d3fc423661eca39211800a0a97
MD5 ace2f172494d5e2e0652ed2baf86d44f
BLAKE2b-256 9894a8b3ea554668da28423b2409cac6e886b5e49ae404b36a7a7fcd2c77805a

See more details on using hashes here.

File details

Details for the file bfast_py-1.0.3-cp38-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for bfast_py-1.0.3-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 33b4faf4c568db1b3e716c2d1ea463281b97e77d605a0bb6bc9cc222d3c53ec4
MD5 b1961d5ca484b1ccccbc3e546278bd24
BLAKE2b-256 c7e7dc960ea30e2e757a6e83a80c93c88cd7947f86964b7ffdc2eaf20f20cc25

See more details on using hashes here.

File details

Details for the file bfast_py-1.0.3-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bfast_py-1.0.3-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e6efac63e0aa139d6223ce17f9a7cda1a56bd01b42cd28527dd1474245957912
MD5 f9076d6667f1ab5b01b73b71ea813130
BLAKE2b-256 0b13d4d3e1e1cfc3755f95c111937171576fee895b17a2cfb72d14dd9cba8beb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page