r/Python • u/cirospaciari • Nov 08 '22
Intermediate Showcase Socketify.py - Maybe the fastest web framework for Python and PyPy
This year i started a journey to bring a really fast framework for Http, Http2, Http3 and WebSockets to Python and PyPy.
The problems with japronto and uvloop
Japronto don't get any github updates since 2020 and don't get any src update since 2018, japronto don't support SSL, WebSockets, PyPy3, Windows or macOS Silicon.
I really needed good support + performance, not only performance.
Almost any solution out there have a really big performance hit when using PyPy3 or are not really fast enougth
The Solution
We discover a really fast, small, and well maintained C++ Library called uNetworking/uWebSockets, but no C API available, so we create and adapt the full C API from uNetworking/uWebSockets and will integrate libuv powered fetch and file IO, this same C API is used by Bun
Benchmarking
We got about 770k req/s with the current version vs 582k from japronto using TechEmPower plaintext benchmarks and we still can get at least 30% or more performance once fully integrated with libuv + asyncio.
Socketify.py brings:
- WebSocket with pub/sub support
- Fast and realiable Http/Https
- Support for Windows, Linux and macOS Silicon & x64
- Support for
PyPy3andCPython
This project aims to bring high performance PyPy3 web development and will bring:
- Fetch like API powered by libuv
- Async file IO powered by libuv
- Full asyncio integration with libuv
- Full Http3 support
HPyintegration to better supportCPython,PyPyandGraalPython
Install
For macOS x64 & Silicon, Linux x64, Windows
#or specify PyPy3
#or in editable mode
Code Example
=
Support
Socketify is an active project and will be maintained over time with security updates and new features and will be commercial support available
Check our github page: https://github.com/cirospaciari/socketify.py
2
u/trowawayatwork Nov 10 '22
probably the slowest to pronounce package name
2
u/re-masashi Mar 26 '23
Great work. Will try making an API using this.