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!
✨ 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 sessionget(url, *, headers=None, params=None)
: Perform GET requesturl
: Target URL (string)headers
: Optional dictionary of headersparams
: 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
- Install Rust and Python development dependencies
- Clone the repository
git clone https://github.com/theoneandonlyacatto/sharphttp
cd sharphttp
- 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
Release history Release notifications | RSS feed
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.