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:
- I prefer python packages without dependencies on debian packages.
- 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.
- 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.
- 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
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
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
Built Distributions
Hashes for pyfrpc-0.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 945c015bd561b1051e8cc1a803b9c9ea5f9ef81d997a0a2b187056091858b9eb |
|
MD5 | e9f41d11ef41759c07547ffe4b83f414 |
|
BLAKE2b-256 | 2c0021c6b99e2c2d67127f1f6133fdcf45da6803b0f1cde5648dcc757d977af7 |
Hashes for pyfrpc-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c894ee2d8e1bd4f1c687cfa2ab1a97bcd1fb20f8aadaf0efba8f1630cb31895 |
|
MD5 | 70aecde22dd34bd8d3c98f985de637d2 |
|
BLAKE2b-256 | 310645677a1cd5fbd64bb396b4bf48a529c0bb8911088d04353e27ed3a49242a |
Hashes for pyfrpc-0.2.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 532fd2a56d8a089a54fccb8092784e9b96f488a3852ff9ad39dd140dfcc79074 |
|
MD5 | 086728bb45e02f4fe6d0bb11caefceb8 |
|
BLAKE2b-256 | 2044810b79750bba8f3773eb719f29440a7eb15e7f1060cb59f7c55ee2ab7901 |
Hashes for pyfrpc-0.2.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0c29c29efbad73ea4d240aae6c24c4a07cbc9128fd4f373826e2bf19c0e0364 |
|
MD5 | d90103d54bf25ec7717f0ee2be258f39 |
|
BLAKE2b-256 | 1803d40bcb6751064964a72048c48ea051185c0b14bc5d15944dbb3fe8c20d38 |
Hashes for pyfrpc-0.2.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 862d81db56e05b3b5d9bfb38921f9438997f1547b10c78fbabe4f9fd56bb318c |
|
MD5 | be01ea98c28e041270f50272e0a21687 |
|
BLAKE2b-256 | 8a42d902b1e98620ad01ff54abd1087351de84e130acc27f71bd71aa79c13429 |
Hashes for pyfrpc-0.2.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06ed69af2cefc4fe03125ccf2246a37c402906bd7cfe103eb95453e51cc1ae36 |
|
MD5 | b4428faff93f366d82a1c34095f26c47 |
|
BLAKE2b-256 | ab91ff89f23a282c6b820a95352088e408808876ece32e7c14975461949129b2 |