pace-python
Rust-powered rate limiting for Python. Native engine via PyO3 — no Redis, no network hop, sub-millisecond decisions.
Install
pip install pace-python
Quick Start
from pace_sdk import Pace, PaceConfig, ProtectionMode, Algorithm
pace = Pace(PaceConfig(
mode=ProtectionMode.ACTIVE,
algorithm=Algorithm.TOKEN_BUCKET,
capacity=100,
refill_rate=10.0,
))
result = pace.check(ip="127.0.0.1", route="/api/generate")
if result.allowed:
print("✅ Request allowed")
else:
print(f"🚫 Blocked — reason: {result.reason}")
Algorithms
| Algorithm | Config Fields |
|---|---|
TOKEN_BUCKET |
capacity, refill_rate |
LEAKY_BUCKET |
capacity, refill_rate |
FIXED_WINDOW |
capacity, window |
SLIDING_WINDOW |
capacity, window |
Modes
ProtectionMode.ACTIVE # blocks requests over limit
ProtectionMode.SHADOW # logs but never blocks
ProtectionMode.DISABLED # zero overhead passthrough
FastAPI
from fastapi import FastAPI, Depends
from pace_sdk import Pace, PaceConfig, ProtectionMode, Algorithm
app = FastAPI()
pace = Pace(PaceConfig(
mode=ProtectionMode.ACTIVE,
algorithm=Algorithm.SLIDING_WINDOW,
capacity=100,
refill_rate=10.0,
))
@app.post("/api/generate", dependencies=[Depends(pace.middleware_fastapi())])
async def generate():
return {"success": True}
Flask
from flask import Flask
from pace_sdk import Pace, PaceConfig, ProtectionMode, Algorithm
app = Flask(__name__)
pace = Pace(PaceConfig(
mode=ProtectionMode.ACTIVE,
algorithm=Algorithm.TOKEN_BUCKET,
capacity=100,
refill_rate=10.0,
))
app.before_request(pace.middleware_flask())
@app.route("/api/generate", methods=["POST"])
def generate():
return {"success": True}
Debug Output
pace = Pace(PaceConfig(
mode=ProtectionMode.ACTIVE,
algorithm=Algorithm.TOKEN_BUCKET,
capacity=3,
refill_rate=1.0,
debug="pretty" # or "compact"
))
│ IP: 127.0.0.1
│ Algorithm: token_bucket
│ Reason: token_exhausted
│ Mode: active
│ Remaining: 0
│ Latency: 0ms
└────────────────────────────────────────
Connect to Pace Cloud
pace = Pace(PaceConfig(
mode=ProtectionMode.ACTIVE,
algorithm=Algorithm.TOKEN_BUCKET,
capacity=100,
refill_rate=10.0,
api_key="your-api-key",
))
License
Apache 2.0 © Suvodeep Mishra
Metadata
Release files for pace-python 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pace_python-1.0.6-cp38-abi3-win_amd64.whl | CPython 3.8 | abi3 | Windows x86-64 | Details for pace_python-1.0.6-cp38-abi3-win_amd64.whl |
| pace_python-1.0.6-cp38-abi3-manylinux_2_34_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.34+ x86-64 | Details for pace_python-1.0.6-cp38-abi3-manylinux_2_34_x86_64.whl |
| pace_python-1.0.6-cp38-abi3-macosx_11_0_arm64.whl | CPython 3.8 | abi3 | macOS 11.0+ ARM64 | Details for pace_python-1.0.6-cp38-abi3-macosx_11_0_arm64.whl |
Total release size: 989.5 kB
Release files / pace_python-1.0.6-cp38-abi3-win_amd64.whl
| Download URL | pace_python-1.0.6-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 241.3 kB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
44380cd84cc04ec4cd3b1793dc1f88b40c5fec171cba074eb970a1aad818bbbb
|
|
BLAKE2b-256 checksum How to use checksums |
7b8c995405e9897daf9c2c064b3e35546ff0c49a3a196dcff58aea50c3bf9e95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / pace_python-1.0.6-cp38-abi3-manylinux_2_34_x86_64.whl
| Download URL | pace_python-1.0.6-cp38-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 402.6 kB |
| Tags | CPython 3.8 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
71c37937d664d9297e8464f04d8a9c05057940f7dd481c85c57e71bb40f36461
|
|
BLAKE2b-256 checksum How to use checksums |
bbb395dda751bebdc597c71313140fae534f75ce2266d026af8f5a2b717be7ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / pace_python-1.0.6-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | pace_python-1.0.6-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 345.6 kB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
536e698d04fecd5762c595b7bb526478149fc5af1ea8fa2e3f801e006602e38e
|
|
BLAKE2b-256 checksum How to use checksums |
9b75b05f7f43abe0a9d192102b029871826ac986778ac8a2cc147a7c80b08958
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for pace-python 1.0.6
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.