Fast websocket client and server for asyncio
Project description
picows is a library for building WebSocket clients and servers with a focus on performance.
Performance
picows is implemented in Cython and thus provides unparallel performance comparing to other popular websocket libraries.
The above chart shows the performance of echo clients communicating to a server through a loopback interface using popular python libraries. boost.beast client is also included for reference. Typically picows is ~ 1.5-2 times faster than aiohttp. All python clients use uvloop. Please find the benchmark sources here
Installation
picows requires Python 3.8 or greater and is available on PyPI. Use pip to install it:
$ pip install picows
Rationale
Popular websocket libraries attempt to provide high level interfaces. They take care of optional decompression, assembling websocket messages from frames, as well as implementing async iteration interface. These features come with a significant cost even when messages are small, unfragmented (every websocket frame is final) and uncompressed. Async iteration interface is done using Futures and it is an extra work for event loop, plus it introduce delays. Furthermore it is not always possible to check if more messages have already arrived, sometimes it is only last message that matters.
Features
Maximally efficient websocket frame parser and builder implemented in cython
Re-use memory as much as possible, avoid reallocations, avoid unnecessary python object creations
Provide cython .pxd for efficient integration of user cythonized code with picows
Ability to check if a frame is the last one in the receiving buffer
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 Distribution
File details
Details for the file picows-0.1.3.tar.gz
.
File metadata
- Download URL: picows-0.1.3.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86fc643665a6f0a9ec9e92ecacf0fb75de7531c0113790acd46c4c9666820dc8 |
|
MD5 | 203a806397dbd501b9e7409fae17eac9 |
|
BLAKE2b-256 | 1fe27b9c3b258b87a39c6e9cbd916e7449434c725662d029706cd34a0b049845 |