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
Aside from distribution as a python package, it's also possible to download single-file amalgamated distribution: pyfrpc.py.
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.3-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d94446aa44ee71151dccca82a7bdb814793d7eb093a31b2350129cb89b4ce51 |
|
MD5 | adfeaff1efcb4bbb563abb2fc10169df |
|
BLAKE2b-256 | 808a2bc842dd2f2f3e0c683e6a721ff479f53e2fccef9b7fa2ebc80ddd21b9cb |
Hashes for pyfrpc-0.2.3-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e952d5ac7bf969bbe811a06de5e7509ce35c36c3e33aa5e2948caa7c5b16a66 |
|
MD5 | 186ffe185bf4ee69dd6e8180e94f0a1b |
|
BLAKE2b-256 | b106a7fe7f088a10078394fd6d480118560a54f7d6a0abbfadba0da48fd53f28 |
Hashes for pyfrpc-0.2.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b13c713b29271caeb11923c463b61457021f36fcdc3738d74586fa44098594d |
|
MD5 | ed60eae95fecda977c346c613544f762 |
|
BLAKE2b-256 | f8a8f4a7d7aa1692ef4f6122e73fe8ca0f752ffb21a91b5c706e28099241acd9 |
Hashes for pyfrpc-0.2.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9593fefb3efcc0de1a9964987d8b2b6c3feac71d40d98cd221bdcc2b20512958 |
|
MD5 | b1f3e300b6f2b222b4137825c64392d9 |
|
BLAKE2b-256 | f82e31de6798a887fe73ced393489fb3d2f5b2e6b99cf9f0990ba503164b3f18 |
Hashes for pyfrpc-0.2.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1dbb0340e56f0a6cfbf6cd6870a818539620d20c3952083a30e982be720b4ed |
|
MD5 | f421f345a9767f6791151f840f174a18 |
|
BLAKE2b-256 | 0dbb209026e52bf6b7cbb3f1ba505ffce3f428f68c6ff3c0285a6a61ffd48cc0 |
Hashes for pyfrpc-0.2.3-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b26cfd07d33ba0c0078ae7cf4c715a40a713364c487cec219bfedbf2ba21301 |
|
MD5 | 853987df592d9f2207dec3759b5f7b2f |
|
BLAKE2b-256 | 57a05ec2bfb1557c05678e77c7de11709249d49f5f88f5b7b535e89286f820dc |