Skip to main content

📦 b4n1-boost

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

License PyPI Python Tests

⚡ Performance at a Glance

Component Metric vs stdlib
JSON dumps (orjson) 10.5x faster Medium dicts (20 users)
JSON dumps (orjson) 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 simd-json + zstd
PyO3 0.28 Free-threading support
Tests 772 passing Unit + Integration + ASGI + Edge Cases

📦 Installation

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 (uses orjson when available, 10x faster)
result = NativeJson.dumps({"users": [...]})

# Direct PyO3 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

# Rust-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.3', '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

🔗 Links


📄 License

Business Source License 1.1 (BSL 1.1).

  • 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.

Download files

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

Source Distribution

b4n1_boost-0.3.3.tar.gz (149.4 kB view details)

Uploaded Source

Built Distributions

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

b4n1_boost-0.3.3-cp310-abi3-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

b4n1_boost-0.3.3-cp310-abi3-manylinux_2_28_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

b4n1_boost-0.3.3-cp310-abi3-manylinux_2_28_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

b4n1_boost-0.3.3-cp310-abi3-macosx_11_0_arm64.whl (2.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

b4n1_boost-0.3.3-cp310-abi3-macosx_10_12_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file b4n1_boost-0.3.3.tar.gz.

File metadata

  • Download URL: b4n1_boost-0.3.3.tar.gz
  • Upload date:
  • Size: 149.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for b4n1_boost-0.3.3.tar.gz
Algorithm Hash digest
SHA256 07e03eff4fb3aec6927e1dc53c034c6966751422568ec4765bae00de08093c4d
MD5 a1644f0500c9c1d57119824c65306378
BLAKE2b-256 448d76efdbf1adb26e7dae6c49f62a4ac82eef3ea02006be8d5d093e7db9ea7e

See more details on using hashes here.

File details

Details for the file b4n1_boost-0.3.3-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: b4n1_boost-0.3.3-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for b4n1_boost-0.3.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0687caf42673b48b672e6be8e5b9bcadf24fdb7ba9924ee210a9f89698900131
MD5 157a015e4d3406a7792939789c2c0f61
BLAKE2b-256 65ecdbdbb7c4c49653779cf4cd8d3e62deff3b69d75880cbd25e169855d8094f

See more details on using hashes here.

File details

Details for the file b4n1_boost-0.3.3-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for b4n1_boost-0.3.3-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 02bdfa827a02d9319d5814dbe2feddd84cab8bb6b84c10d608fd3ec8745c3fd8
MD5 0f35878b53b5fc3c5dbba9167f73f643
BLAKE2b-256 b2aabec9c056c80c55da7989d83712b04082a05af5e6065d881ffda2b07c5b79

See more details on using hashes here.

File details

Details for the file b4n1_boost-0.3.3-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for b4n1_boost-0.3.3-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 524f13f0e5b2c7c9f29efbf9ea4105bffecc2c980ccd7d35fec9f5911a8a03ea
MD5 5f063d00077586d0247764709adc7d37
BLAKE2b-256 9a5d1cacb894bdbcae7a2e1fdce7bbd0a60c1914c191cabf2d74d0699963b008

See more details on using hashes here.

File details

Details for the file b4n1_boost-0.3.3-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for b4n1_boost-0.3.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bca297f4f96f7f3393a67441f4d665335835d23f07a23ea935b3b6b44e794c13
MD5 92ddfd47180e796601d72abd64f681d8
BLAKE2b-256 395e8f81b4d3e8024e255dda77a3cc09a8b25f85a3989db2695ac946f690f5e5

See more details on using hashes here.

File details

Details for the file b4n1_boost-0.3.3-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for b4n1_boost-0.3.3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7ba53f6e6ed007c754167697373cce5270df2a889e3b68bcca49613c885b114c
MD5 8798368725fd66a625c7c89269699943
BLAKE2b-256 20836a33fa2cbeaa61a06082ed8f8aa25a947f0cb4d202009952ac01b5247c82

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.4

6 files

This release

0.3.3 This release

6 files

0.3.2

2 files

0.3.1

2 files

0.3.0

6 files

0.1.9

6 files

0.1.8

7 files

0.1.6

6 files

0.1.5

2 files

0.1.4

4 files

0.1.3

3 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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