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
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.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cf436c6fbfa791554127d29be07a68d6d6d5ee6f3d2228c5fb12ca48b9e9e43 |
|
MD5 | 873a902511f99ed1a5e793bcdd6fc58b |
|
BLAKE2b-256 | fc9a9d6d10861c9f4ee961f61e3eb04fd3644f376327dd9ad8ec9f3df0113b38 |
Hashes for pyfrpc-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a5b51cf99e5deccce7686ecf68b1466845a8a6e8e0df83aa71d0a044938e07d |
|
MD5 | 9b11b279536cf60b8bb2a970595c8dad |
|
BLAKE2b-256 | fefe99f1e6c6d229414bf00ff6eaf340c4d449b7c9f6533d694e6621378e4352 |
Hashes for pyfrpc-0.2.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58635d27e6faaab335222a8850c12219101b20bdec7e403bcc6668a93cd07e6e |
|
MD5 | 39092f043873f3e51829ab097af01f3a |
|
BLAKE2b-256 | 672e0a749091e1673eb9e0c53879d50ce13f2ebff6e0654cd63a149a0497dba4 |
Hashes for pyfrpc-0.2.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b9fcffa04aac13024c2aebe97f7f9c04a5f5987e90065d36ec6131db61aa650 |
|
MD5 | 1a8de7724e77e0e61336ec14d090da26 |
|
BLAKE2b-256 | 0e3b5b27d4d0f4b7104e2c278bac26e8dcc5fd729326ccf58780db27fc1be973 |
Hashes for pyfrpc-0.2.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac5b1d1dd8db22f2c6d35caed771a54358fcb259489edd84d11ef64135abe802 |
|
MD5 | 917b4e2331320e177e397440970bee9f |
|
BLAKE2b-256 | 2b0c7ff7fab77b626c0dad1f9e953fc8d846921b6cbb4166868a6dcf6aecbd88 |
Hashes for pyfrpc-0.2.6-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e618db22c8eb642019d99d7b028d063c6a5f540b8c7b0b5a92eb8bdf0fae9a5 |
|
MD5 | f556ede6584f9e953e747ac927855bf8 |
|
BLAKE2b-256 | 03382a47383785f7aaf181fff61b99ef29db83c91cf00596e8d18c39f74bdbf8 |