Skip to main content

A fast HTTP client implementation in Rust for Python

Project description

🚀 SharpHTTP

A blazingly fast HTTP client implementation in Rust for Python, offering exceptional performance and reliability!

PyPI version License: MIT

✨ Features

  • 🏃‍♂️ Lightning Fast: Up to 3.3x faster than aiohttp
  • 🔒 Secure: Built on top of hyper-tls
  • 🔄 Async-First: Native async/await support
  • 🛠 Resource Efficient: Optimized connection pooling and memory usage
  • 🌐 HTTP/2 Support: Modern protocol features out of the box

🚄 Performance

Real-world benchmarks show significant performance improvements over other popular HTTP clients:

Client Mean (ms) Min (ms) Max (ms)
SharpHTTP 13.50 9.41 26.18
aiohttp 45.06 21.79 1062.42

SharpHTTP is 233.7% faster on average! 📈

🔧 Installation

pip install sharphttp

📚 Usage

import asyncio
from sharphttp import ClientSession

async def main():
    async with ClientSession() as session:
        # Simple GET request
        response = await session.get('https://api.example.com/data')
        
        # Print response status
        print(response.status)  # 200
        
        # Get response text
        text = await response.text()
        print(text)

        # With headers and query parameters
        response = await session.get(
            'https://api.example.com/search',
            headers={'Authorization': 'Bearer token'},
            params={'q': 'search term'}
        )

asyncio.run(main())

🔍 API Reference

ClientSession

The main interface for making HTTP requests.

Methods

  • __init__(): Create a new client session
  • get(url, *, headers=None, params=None): Perform GET request
    • url: Target URL (string)
    • headers: Optional dictionary of headers
    • params: Optional dictionary of query parameters

Response

Represents an HTTP response.

Properties

  • status: HTTP status code (int)
  • headers: Response headers (dict)

Methods

  • text(): Get response body as text (async)

🏗 Building from Source

  1. Install Rust and Python development dependencies
  2. Clone the repository
git clone https://github.com/theoneandonlyacatto/sharphttp
cd sharphttp
  1. Build the package
pip install maturin
maturin develop --release

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📝 License

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

🙏 Acknowledgments


Made with ❤️ by acatto

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 Distribution

sharphttp-0.3.0-cp312-none-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.12 Windows x86-64

File details

Details for the file sharphttp-0.3.0-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for sharphttp-0.3.0-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 b7550fbcf597da6a4a5923a128d4b1f1abee0a63fc6e71c55612be468e60b428
MD5 52102d5879030d02456a00f19b8b2416
BLAKE2b-256 102533d79cb638d965352f92bff1338ca7673b6521ff691d9368f5f5064ef1ae

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page