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.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 463f8027884f80a07b48120753221216584ea47f0366a1572f024f14845fa30e |
|
MD5 | 5f9720208456b2d290e83c6e4764b261 |
|
BLAKE2b-256 | cd62f708c9970307608478e1dd5d507836063e39647847333e86bcbb57874d4c |
Hashes for pyfrpc-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78df782b890538f0e7dff6f6058429d266effb74d010ca503f7cac05789c0d6f |
|
MD5 | a659996b515c0399f18065563326eb15 |
|
BLAKE2b-256 | ee252f097f5ca87a1fee609be186b5be9f7b1d241fc65313ccfa7396f1ecb98f |
Hashes for pyfrpc-0.2.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 612974813328263de80adad981adf7eadbde453059d1d9df4d4722fdafcc663e |
|
MD5 | 0ab2b5656ae2aa5850c61cbef7b713d2 |
|
BLAKE2b-256 | 1e648f195108a7b83c53c4005f32c83f5ee4d2aca8a26574f2e875011dc5da9f |
Hashes for pyfrpc-0.2.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fce693d330c09b4b377d778026ca02f859959d8cc8dfb9459384815e8460432 |
|
MD5 | 83e9c7b84d37936db74b16ceef92f66a |
|
BLAKE2b-256 | bd1ba99fc09c5602e93f4ae49f070ff8dc0bc1e47bf405edb4ac433954c75b02 |
Hashes for pyfrpc-0.2.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d4f9529b16cc601299fa8dfa4a4e177c53594b7fed0a05c7abddbce329416e3 |
|
MD5 | dd81f2481def8bf88513224931de07dd |
|
BLAKE2b-256 | 6f42bc3cb2ccb1410238d2dba65f648da5eb27a487c9c8ab3dd9863336d32c12 |
Hashes for pyfrpc-0.2.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02b30ddbb5c8d4c8595422ada78ce3ed158ccf03f02bfbaf43af24402f491f78 |
|
MD5 | 2cd27d52728b4f2660c3a47b4343660a |
|
BLAKE2b-256 | 77f50a893f26ddcd154998063cb0f8c3dad69e9486b593bebb77b50c9c88c5f4 |