Skip to main content

A high-performance HTTP client for Python

Reason this release was yanked:

Superseded by 2.0.0; API incompatible

Project description

HyperHTTP

PyPI version Python Versions License: MIT Documentation Status Tests Code Coverage

HyperHTTP is a revolutionary HTTP client library for Python that achieves unprecedented performance while being written entirely in pure Python. Unlike other popular libraries that rely on C extensions or CPython bindings (like requests and httpx), HyperHTTP demonstrates that Python can be blazingly fast when designed with performance in mind.

Through innovative architecture and optimization techniques, HyperHTTP delivers:

  • 15% faster than aiohttp and 20% faster than httpx in real-world benchmarks
  • 4.5x lower memory consumption than httpx and 4.4x lower than aiohttp
  • Native HTTP/2 support with optimized stream handling
  • Zero external dependencies for core functionality

Built with modern Python features and a focus on asyncio, HyperHTTP proves that pure Python implementations can outperform C-based alternatives when designed with performance as a first-class concern. It's the perfect choice for high-throughput applications where speed and resource efficiency matter.

🚀 Features

  • Ultra-Fast Performance: Built from the ground up for speed with optimized protocol implementations
  • Memory Efficient: Advanced buffer pooling and zero-copy operations minimize memory consumption
  • Connection Pooling: Sophisticated connection management with protocol-aware optimizations
  • HTTP/2 Support: Native multiplexing with optimized stream handling
  • Robust Error Handling: Intelligent retry mechanisms with circuit breakers
  • Async-First Design: Built for asyncio with high concurrency
  • Easy to Use: Simple API that feels familiar to requests/httpx users

📦 Installation

pip install hyperhttp

For optional dependencies:

# For development
pip install hyperhttp[dev]

# For testing
pip install hyperhttp[test]

# For documentation
pip install hyperhttp[doc]

⚡ Quick Start

import asyncio
from hyperhttp import Client

async def main():
    client = Client()
    
    # Simple GET request
    response = await client.get("https://example.com")
    print(f"Status: {response.status_code}")
    print(f"Body: {await response.text()}")
    
    # POST with JSON
    response = await client.post(
        "https://httpbin.org/post",
        json={"key": "value"}
    )
    data = await response.json()
    print(data)
    
    await client.close()

if __name__ == "__main__":
    asyncio.run(main())

📊 Performance

Library Requests/sec Peak Memory (MB) P95 Latency (ms) P99 Latency (ms)
hyperhttp 24.78 1.78 835.02 1425.82
aiohttp 24.28 0.39 886.27 1451.86
httpx 21.52 1.01 1081.06 2028.91

Benchmark: 1,000 concurrent GET requests to httpbin.org/get

Key findings:

  • HyperHTTP achieves the highest throughput (24.78 req/sec)
  • Lowest P95 and P99 latencies among all tested libraries
  • Memory usage is optimized for high concurrency scenarios
  • Zero failed requests across all test runs

📚 Documentation

For detailed documentation, visit our documentation site.

🛠️ Advanced Usage

Parallel Requests

async with Client() as client:
    # Create tasks for parallel execution
    tasks = [
        client.get("https://httpbin.org/get"),
        client.get("https://httpbin.org/ip"),
        client.get("https://httpbin.org/headers")
    ]
    
    # Execute all requests in parallel
    responses = await asyncio.gather(*tasks)

Custom Retry Policy

from hyperhttp import Client
from hyperhttp.errors.retry import RetryPolicy
from hyperhttp.utils.backoff import DecorrelatedJitterBackoff

retry_policy = RetryPolicy(
    max_retries=5,
    retry_categories=['TRANSIENT', 'TIMEOUT', 'SERVER'],
    status_force_list=[429, 500, 502, 503, 504],
    backoff_strategy=DecorrelatedJitterBackoff(
        base=0.1,
        max_backoff=10.0,
    ),
    respect_retry_after=True,
)

client = Client(retry_policy=retry_policy)

Connection Pooling

client = Client(
    max_connections=100,  # Total connections across all hosts
)

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Inspired by the performance needs of modern web applications
  • Built with ❤️ by Latiful Mousom

📞 Support

Project details


Download files

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

Source Distribution

hyperhttp-1.1.0.tar.gz (49.3 kB view details)

Uploaded Source

Built Distribution

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

hyperhttp-1.1.0-py3-none-any.whl (58.0 kB view details)

Uploaded Python 3

File details

Details for the file hyperhttp-1.1.0.tar.gz.

File metadata

  • Download URL: hyperhttp-1.1.0.tar.gz
  • Upload date:
  • Size: 49.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for hyperhttp-1.1.0.tar.gz
Algorithm Hash digest
SHA256 4c9d74c20314e9a9c617ce86045a7cc5203b23c0f8a53779e61b45407f9a34c9
MD5 3d346ca58e6caf222bec9b112472e206
BLAKE2b-256 bc94e1f3d6d98493e44e16f59ff497666c07cdfe677ae4f2021dc0f735e37b11

See more details on using hashes here.

File details

Details for the file hyperhttp-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: hyperhttp-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 58.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for hyperhttp-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95d43c5caea670927760758113d6490903bfb3b45454502f076e2d1fe8fd2723
MD5 38ce5efc8f8f4e915f1bb0719f7c4acb
BLAKE2b-256 3afd371032f5692fac7a66061a0893b186da06e1bb8419cab340e05b67d17858

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