Posts about PyPy
This year i started a journey to bring a really fast framework for Http, Http2, Http3 and WebSockets to Python and PyPy.
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
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
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.
WebSocket with pub/sub support
Fast and realiable Http/Https
Support for Windows, Linux and macOS Silicon & x64
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
HPy
integration to better supportCPython
,PyPy
andGraalPython
For macOS x64 & Silicon, Linux x64, Windows
pip install git+https://github.com/cirospaciari/socketify.py.git
#or specify PyPy3
pypy3 -m pip install git+https://github.com/cirospaciari/socketify.py.git
#or in editable mode
pypy3 -m pip install -e git+https://github.com/cirospaciari/socketify.py.git@main#egg=socketify
from socketify import App, AppOptions
app = App(AppOptions(key_file_name="./misc/key.pem", cert_file_name="./misc/cert.pem", passphrase="1234"))
app.get("/", lambda res, req: res.end("Hello World socketify from Python!"))
app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port))
app.run()
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
In socketify.py project i chose to support PyPy to get the performance close to Go Fiber, today i implemented one optimization, to reuse requests, responses and websockets objects to avoid dynamic allocations and GC pass. PyPy is just a beast, and i have a lot to optimize yet.
https://github.com/cirospaciari/socketify.py
If you want to try run on your machine you can clone https://github.com/cirospaciari/FrameworkBenchmarks
Commands used to run on Debian GNU/Linux bookworm/sid x86_64 - kernel 6.0.0-2
sudo ./tfb --mode benchmark --test socketify.py --type plaintext
sudo ./tfb --mode benchmark --test socketify.py-python3 --type plaintext
sudo ./tfb --mode benchmark --test fiber --type plaintext