Skip to main content

Python implementation of fastrpc protocol

Project description

Pyfrpc

Pyfrpc is a Python implementation of FastRPC protocol/library ( @github or @sourceforge ). The original library contains Python bindings, but:

  1. I prefer python packages without dependencies on debian packages.
  2. Its flexibility is limited in some points. E.g. the library provides its own implementation of HTTP server and client, which is nice to have in C++, but not in Python I would say as there are already full-featured and more mature libraries available for those tasks.
  3. In my opinion it's not worth to wrap such a library for python anyway (at least not from today's perspective). The original binding itself is 3500 lines of code. So this is an alternative aproach.
  4. And I want to use it as a showcase for cython as well.

This library provides FastRPC encoding/decoding functions, FastRPC client (based on 'requests') and an interactive FastRPC client/terminal 'pyfrpc' (an alternative to 'fastrpc-netcat' based on 'IPython'). API mostly differs and is not meant to be a drop-in replacement.

It is compatible with protocol versions 1.0, 2.0, 2.1 and 3.0.

Package provides both cython (C extencion) and pure python implementations. Cython implementation is faster but requires C toolchain (or available python wheels). To use pure python implementation set env variable PYFRPC_NOEXT=1 during installation.

Some features missing are:

  • handling of base64 encoded FastRPC
  • helper to build a server

Interactive client

Interactive client opens na ipython session with varible client initialized to FastFRPC connection. It supports tab-based completion of remote procedures' names as well as shownig their documentation using question mark notation as is usual in ipython.

$ pyfrpc --help

usage: pyfrpc [-h] [--insecure] URL

FRPC netcat for interactive connection to FRPC server

positional arguments:
  URL         URL of FRPC server to connect to

optional arguments:
  -h, --help  show this help message and exit
  --insecure  Do not check server's cert
$ pyfrpc http://my-avesome-server

In [1]: client.greeting?
...
Docstring:   Prints greeting.

In [2]: client.greeting()
Out[2]: 
'hello from server'

Benchmark

2024-01-02, Python3.11 @ debian bookworm:

+------------------------+----------+----------+----------+
| description            | encoding | decoding | total    |
+------------------------+----------+----------+----------+
| orjson                 |    0.3ms |    0.9ms |    1.2ms |
| pyfrpc                 |    0.6ms |    1.2ms |    1.8ms |
| fastrpc                |    0.8ms |    1.7ms |    2.6ms |
| ujson                  |    1.8ms |    2.1ms |    3.9ms |
| json                   |    2.6ms |    1.4ms |    4.1ms |
| pyfastrpc              |   12.8ms |   18.3ms |   31.1ms |
+------------------------+----------+----------+----------+

2020-12-02, Python3.7 @ debian buster:

+------------------------+----------+----------+----------+
| description            | encoding | decoding | total    |
+------------------------+----------+----------+----------+
| pyfrpc                 |    1.6ms |    3.6ms |    5.3ms |
| ujson                  |    5.1ms |    4.7ms |    9.9ms |
| fastrpc                |    3.2ms |    7.0ms |   10.2ms |
| json                   |    7.0ms |    5.2ms |   12.3ms |
| pyfastrpc              |   59.2ms |   77.2ms |  136.3ms |
+------------------------+----------+----------+----------+

2017-12-29, benchmarks during library development:

+------------------------+----------+----------+----------+
| description            | encoding | decoding | total    |
+========================+==========+==========+==========+
| fastrpc (original lib) |   1.7 ms |   5.7 ms |   7.5 ms |
+------------------------+----------+----------+----------+
| python                 |  35.1 ms |  25.8 ms |  60.8 ms |
+------------------------+----------+----------+----------+
| pypy                   |  12.6 ms |   5.2 ms |  17.8 ms |
+------------------------+----------+----------+----------+
| cython (naive)         |  17.9 ms |  43.1 ms |  61.0 ms |
| cython (cdef)          |  11.9 ms |  22.6 ms |  34.4 ms |
| cython (static typing) |   2.2 ms |   3.7 ms |   5.9 ms |
| cython (low level api) |   1.3 ms |   3.7 ms |   4.9 ms |
+------------------------+----------+----------+----------+

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

pyfrpc-0.2.13.tar.gz (18.1 kB view details)

Uploaded Source

Built Distributions

pyfrpc-0.2.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (319.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyfrpc-0.2.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (319.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyfrpc-0.2.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (314.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyfrpc-0.2.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (299.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyfrpc-0.2.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (298.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file pyfrpc-0.2.13.tar.gz.

File metadata

  • Download URL: pyfrpc-0.2.13.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pyfrpc-0.2.13.tar.gz
Algorithm Hash digest
SHA256 24ef934a05d73e42d4774674fbd03862306de39c53f9f6bb9ecfd27ac7789228
MD5 3b1e839e044d0fd5deb32c159cde6e09
BLAKE2b-256 cfc75a4368797b4b57b2598c8343806a4dff6ceb5a6fad32d269175b56c61c66

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyfrpc-0.2.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5f37377f88de03e84296780378a440f834b89e9f6a0fbaa943e4e046585b180e
MD5 f3c35fb01e09963defb0d14ecf799233
BLAKE2b-256 e3401eb05da00d479a72ae4cabebfc7588f37aa65e4a19c24f79f1e062006b31

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyfrpc-0.2.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b29d245048823c2ba57bf85f570da83a312f90c11a351d6898217bb39b3ac1aa
MD5 ad42949edc473d97cc0b4a17deceafb9
BLAKE2b-256 ad43af59fb64dfcd590616957ea79c78ab7f49d338c75f393d1f2e873b95b49d

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyfrpc-0.2.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a7fdd3100df86b710f16ea2daa3dfe8e4572430921c0fe0fddce1cf789d8cff8
MD5 1c1f07b54a05de52453e370220844401
BLAKE2b-256 05aef1d4c0e6e409987980ea5475b45a48e189f28dbb69ff084b0cb3c099cdd3

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyfrpc-0.2.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9f761eb6711e12e982d7a53b03dc1b8244029d7330f4e60b8100cb47ea513bd
MD5 4ca0b1f2a82346e7f103d847a33bd97c
BLAKE2b-256 fba118aa8e498b418615a8ab8249574f0165f7500b93be54625ea0eef3b1ace1

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyfrpc-0.2.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e3731c18dbb6a6c48da8bf763b4ff2696c449417a13aaf85d66e8c4e8c97e816
MD5 8a358e71fb988b0a4f7c41bca3a10e0d
BLAKE2b-256 7c3c63e62064c43167a4ad0d89380cf53c10191f2416ab99a2026c5250b362c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page