Skip to main content

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.

https://raw.githubusercontent.com/tarasko/picows/master/docs/picows_benchmark.png

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

picows-0.1.4.tar.gz (12.5 kB view details)

Uploaded Source

File details

Details for the file picows-0.1.4.tar.gz.

File metadata

  • Download URL: picows-0.1.4.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for picows-0.1.4.tar.gz
Algorithm Hash digest
SHA256 88bf604c3d9a0cf815063356ea927d971456f778fa10915bbf015d2a6a5541d7
MD5 3f5fdbbc014dd948d838935c328a69ba
BLAKE2b-256 94457b3a37125930169289e3671c9bff159736d878f9328d9400c9ffb2bdc77d

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