Skip to main content

📦 b4n1-boost

The Python Accelerator. Native middleware for Django, FastAPI, Flask — JSON 10x faster, compression 28x faster.

License Version Docs PyPI npm Python Tests

📚 Full manual (installation, middleware, accelerators, performance): https://b4n1-com.github.io/b4n1-boost/

🖥 Platform Support

Platform Architectures
Linux x86_64, aarch64
macOS x86_64, arm64 (Apple Silicon)
Windows x86_64

Pre-compiled binaries for every platform — no compiler required, works out of the box.


📦 Installation

Registry Package Command
PyPI b4n1-boost pip install b4n1-boost
npm b4n1-boost npm install b4n1-boost
NuGet B4N1.Boost dotnet add package B4N1.Boost
Maven com.b4n1:boost implementation 'com.b4n1:boost:0.3.13'

📚 Usage examples for Node.js, .NET and Java, middleware reference and benchmarks live in the full manual.


Languages: العربية · Deutsch · Español · Français · हिन्दी · Italiano · 日本語 · 한국어 · Português (BR) · Русский · 中文

⚡ Performance at a Glance

Component Metric vs stdlib
JSON dumps (native engine) 10.5x faster Medium dicts (20 users)
JSON dumps (native engine) 8.5x faster Large dicts (500 users)
Gzip (native) 1.47x faster 1MB payloads
Zstd (native) 28x faster 1MB payloads
Brotli (native) Best ratio 1MB payloads
DRF serializer 5-10x faster queryset → JSON
Django ORM PostgreSQL COPY bulk insert native
Wheel size ~1.4MB native, no compiler needed
No-GIL ready Python 3.13+ Free-threading support
Tests 772 passing Unit + Integration + ASGI + Edge Cases

Python (pip)

pip install b4n1-boost

Precompiled native wheels for Linux (x86_64 + aarch64), macOS (x86_64 + Apple Silicon), and Windows (x86_64). No compiler required.

Supported Python versions: 3.10, 3.11, 3.12, 3.13


🚀 Quick Start

Django

import b4n1_boost
report = b4n1_boost.install_django()
# Appends DjangoBoostMiddleware to settings.MIDDLEWARE
# Report shows: {'framework': 'Django', 'middleware_installed': True, ...}

FastAPI

from fastapi import FastAPI
import b4n1_boost

app = FastAPI()
b4n1_boost.install_fastapi(app)

Flask

from flask import Flask
import b4n1_boost

app = Flask(__name__)
b4n1_boost.install_flask(app)

Auto-detection

import b4n1_boost
b4n1_boost.autoboost()  # Detects Django/FastAPI/Flask automatically

One-line install all middleware

import b4n1_boost
report = b4n1_boost.boost_all()
# Applies: compression + ETag + security headers + CORS + rate limiting + health check
# Returns: {'framework': 'Django', 'applied': ['compression', 'etag', ...], 'middleware_count': 6}

🔧 Features

JSON Serialization (10x faster)

from b4n1_boost import NativeJson, canonicalize_json, validate_json

# Fast JSON dumps (native engine, 10x faster)
result = NativeJson.dumps({"users": [...]})

# Direct native path (no intermediate conversion)
result = NativeJson.dumps_direct(data)

# Batch: serialize N objects in a single GIL acquire
results = NativeJson.batch_dumps([obj1, obj2, obj3])

# Canonicalize: sorted keys, compact form (accepts str or dict)
canonicalize_json({"z": 1, "a": 2})  # '{"a":2,"z":1}'

# Fast JSON validation
validate_json('{"valid": true}')  # True

Compression (28x faster, GIL-free)

from b4n1_boost import compress

compressed = compress(payload, "zstd")   # 28x faster than stdlib gzip
compressed = compress(payload, "brotli") # Best ratio
compressed = compress(payload, "gzip")   # 1.47x faster than stdlib

# Static file compression
from b4n1_boost import compress_static_file, compress_static_dir
compress_static_file("app/static/app.js", algorithm="zstd")
compress_static_dir("app/static/", algorithm="zstd")

Content-Type Aware Middleware

from b4n1_boost.middleware import B4N1BoostCompressionMiddleware

# Automatically skips: images, video, audio, fonts, archives, already-compressed
app.wsgi_app = B4N1BoostCompressionMiddleware(app.wsgi_app, min_size=1024)

# For FastAPI/ASGI (streaming support)
from b4n1_boost.middleware import FastAPIBoostCompressionMiddleware
app.add_middleware(FastAPIBoostCompressionMiddleware)

ETag / 304 Caching

from b4n1_boost.middleware import ETagMiddleware
app.wsgi_app = ETagMiddleware(app.wsgi_app)

Rate Limiting

from b4n1_boost.middleware import RateLimitMiddleware
app.wsgi_app = RateLimitMiddleware(app.wsgi_app, max_requests=100, window_seconds=60)

Security Headers

from b4n1_boost.middleware import SecurityHeadersMiddleware
app.wsgi_app = SecurityHeadersMiddleware(app.wsgi_app)
# Adds: X-Content-Type-Options, X-Frame-Options, HSTS, X-XSS-Protection, etc.

CORS

from b4n1_boost.middleware import CORSMiddleware
app.wsgi_app = CORSMiddleware(app.wsgi_app, allow_origins=["https://example.com"])

Health Check

from b4n1_boost.middleware import HealthCheckMiddleware
app.wsgi_app = HealthCheckMiddleware(app.wsgi_app, path="/health")
# GET /health → 200 {"status": "ok"}

Cache Layer

from b4n1_boost.advanced import ResponseCache
from b4n1_boost.middleware import CacheMiddleware

cache = ResponseCache(max_size=1000, ttl_seconds=300)
app.wsgi_app = CacheMiddleware(app.wsgi_app, cache=cache)

Django ORM Accelerator

from b4n1_boost.django_accelerator import bulk_insert_native, FastModelMixin

# PostgreSQL COPY — 5-10x faster than Django ORM
bulk_insert_native(MyModel, [
    {"name": "Alice", "email": "alice@example.com"},
    {"name": "Bob", "email": "bob@example.com"},
])

DRF Serializer Accelerator

from b4n1_boost.drf_accelerator import fast_serialize, FastSerializerMixin

# queryset → JSON without DRF overhead (5-10x faster)
json_bytes = fast_serialize(queryset, fields=["id", "name", "email"])

# Mixin for existing serializers
class MySerializer(FastSerializerMixin, serializers.ModelSerializer):
    class Meta:
        model = MyModel
        fields = ["id", "name"]

JWT Validation

from b4n1_boost.advanced import validate_jwt

# Native HMAC-SHA256 (no PyJWT dependency required)
payload = validate_jwt(token, secret="my-secret", algorithm="HS256")

HTML/CSS/JS Minification

from b4n1_boost.advanced import minify_html, minify_css, minify_js

minified = minify_html("<html>  <body>  Hello  </body>  </html>")

HTML → Markdown (Agentic)

from b4n1_boost import html_to_markdown

markdown = html_to_markdown("<h1>Title</h1><p>Content with <b>bold</b></p>")
# → "# Title\n\nContent with **bold**"

Telemetry

from b4n1_boost import telemetry_init, capture_error, log_info, log_phase, flush

telemetry_init(dsn="https://...")
capture_error(Exception("something"), context={"user": "123"})
log_info("Request processed", phase="http")
flush()

Background Worker (zero-GIL)

from b4n1_boost import worker_compress, worker_decompress, worker_minify_html, worker_validate_jwt

# Heavy ops offloaded to background thread — no GIL contention
future = worker_compress(data, "zstd")
compressed = future.result()

🔍 Status & Diagnostics

import b4n1_boost
print(b4n1_boost.status())
# {'version': '0.3.5', 'native_extension': True, 'features': [...]}
# Run hardware benchmarks
report = b4n1_boost.run_benchmarks(iterations=100_000)
# Generate fresh HTML status report
# python3 generate_report.py --open


📄 License

Business Source License 1.1 (BUSL-1.1) — note this is not the SPDX id BSL-1.1, which denotes the Boost Software License.

  • Free for development, evaluation, testing, personal projects, and startups under $100K USD annual revenue.
  • Commercial license required for organizations >= $100K USD, government agencies, and public bidding.
  • After Change Date (4 years) → Apache License 2.0.

See LICENSE for full text.


b4n1-boost: The Python Accelerator. JSON 10x faster. Compression 28x faster. Middleware transparent. Built with ❤️ by B4N1.

Metadata

Release files for b4n1-boost 0.3.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for b4n1-boost 0.3.13
File Actions
b4n1_boost-0.3.13-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for b4n1_boost-0.3.13-cp310-abi3-win_amd64.whl
b4n1_boost-0.3.13-cp310-abi3-manylinux_2_34_x86_64.whl CPython 3.10 abi3 Linux glibc 2.34+ x86-64 Details for b4n1_boost-0.3.13-cp310-abi3-manylinux_2_34_x86_64.whl
b4n1_boost-0.3.13-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for b4n1_boost-0.3.13-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
b4n1_boost-0.3.13-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for b4n1_boost-0.3.13-cp310-abi3-macosx_11_0_arm64.whl
b4n1_boost-0.3.13-cp310-abi3-macosx_10_13_x86_64.whl CPython 3.10 abi3 macOS 10.13+ x86-64 Details for b4n1_boost-0.3.13-cp310-abi3-macosx_10_13_x86_64.whl

Total release size: 12.2 MB

Release files / b4n1_boost-0.3.13-cp310-abi3-win_amd64.whl

Download URL b4n1_boost-0.3.13-cp310-abi3-win_amd64.whl
Size 2.9 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a6ebdc244e4f2167c1a7979a40e1160f4385b04abec564bc319fe8e5f7ece088
BLAKE2b-256 checksum
How to use checksums
4ee0014975171d92633193d4e9820d9ff4436469408016f67342fdcca0dab2cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / b4n1_boost-0.3.13-cp310-abi3-manylinux_2_34_x86_64.whl

Download URL b4n1_boost-0.3.13-cp310-abi3-manylinux_2_34_x86_64.whl
Size 2.4 MB
Tags CPython 3.10 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
7b423a1f9f82fe3b6e39ef64bcf98355ca7b63a4fe76ed9a4213f9b876bf3b4f
BLAKE2b-256 checksum
How to use checksums
35f85f9066bdaed12869278f18e934dc358af0347802378f9dff81b2c39fc046
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / b4n1_boost-0.3.13-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL b4n1_boost-0.3.13-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.3 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
8633c0408fed46dc62638a930d67f2fe8c7ff4b88fd5e7fe5c17c82b6f9be912
BLAKE2b-256 checksum
How to use checksums
514041b55dc3d12e1b8aa784a414de5140b0d69de3b80e359abf3a7d4efd34d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / b4n1_boost-0.3.13-cp310-abi3-macosx_11_0_arm64.whl

Download URL b4n1_boost-0.3.13-cp310-abi3-macosx_11_0_arm64.whl
Size 2.2 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
06ea7cd9f252637d288815280d364e8e4f91626ee37ae2f9871daaa1bed1c8f3
BLAKE2b-256 checksum
How to use checksums
3561265930c1ea5986d1a56125e529d31beb9543255c0a905e3a1175950324c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / b4n1_boost-0.3.13-cp310-abi3-macosx_10_13_x86_64.whl

Download URL b4n1_boost-0.3.13-cp310-abi3-macosx_10_13_x86_64.whl
Size 2.4 MB
Tags CPython 3.10 abi3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
fbf320af59a5f8fedea32bdd313ffe0dcc36a353ffafece8556e4487b0560586
BLAKE2b-256 checksum
How to use checksums
d33ba0dd46376c8262cf92d7681c7f0e6dc59ff71405503b7c9d8f89671c98f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for b4n1-boost 0.3.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page