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.

📚 Documentação

Documentação completa disponível em: https://marcelomarkus.github.io/b-fast/

🚀 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


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.5-cp38-abi3-win_amd64.whl (154.7 kB view details)

Uploaded CPython 3.8+Windows x86-64

bfast_py-1.0.5-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.5-cp38-abi3-macosx_11_0_arm64.whl (264.5 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: bfast_py-1.0.5-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 154.7 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.5-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f89c70203112da58da879ca1315c0124e34df03e5ae807354a9719382433524a
MD5 f619eaf2c1aadadea7ca89db01afe308
BLAKE2b-256 e6ade2c81dfb59c7fc82e25c10a7c35c94dfb23a47e2be90ebe1740fbb1da670

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bfast_py-1.0.5-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b1bac64773afa24767ad3b609101488398f1193138018bfa6c1260e418dfc165
MD5 00745d83a2d87d515fa49b7deb20936e
BLAKE2b-256 0e7d261b30143f8415a54162bd557aa79674fea6ff32df38f57d07f7ef2ff0ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bfast_py-1.0.5-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 370ab5703c199ec8737d7787cbb82da62dc634e9723666721ff4e6e8db34ccf2
MD5 9e80ce7126d12d9fc104f028696b26a7
BLAKE2b-256 d440b2b9400e6886d4313d49300ab0053536950aa45bd5b5d3a3557089b64e1f

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