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

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.12.tar.gz (17.9 kB view details)

Uploaded Source

Built Distributions

pyfrpc-0.2.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (310.2 kB view details)

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

pyfrpc-0.2.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (306.2 kB view details)

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

pyfrpc-0.2.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (290.0 kB view details)

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

pyfrpc-0.2.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (288.9 kB view details)

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

pyfrpc-0.2.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (292.8 kB view details)

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

pyfrpc-0.2.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (273.4 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.28+ x86-64

File details

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

File metadata

  • Download URL: pyfrpc-0.2.12.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for pyfrpc-0.2.12.tar.gz
Algorithm Hash digest
SHA256 a5c4e037ffff1015656932fe016097855aa4906717fa771844a1f4c1f8df2727
MD5 5f9457e927aaf2f9fe15bfc2213feae9
BLAKE2b-256 bc75bab9e7c47a06b53c9f8b54576a34e3a7cf1f9c150c188ff2ce8dcd18140e

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.12-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.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 383d6e5b440508706a089938602c239d74c29426a28ae61351a659a166cf1cf5
MD5 82a41593e596b94d04e3074eeadc4609
BLAKE2b-256 1c08118583c865309e9abe9f8c7c9f4a7b47c9513631e501ea1059f584816a92

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.12-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.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 79b879773f7a25dd9cccefc9060e41bed6505a731c2acedfb68e53b5d4ea2126
MD5 a7228f2c619da3a9694225e32dac691a
BLAKE2b-256 16ead0a62ee1a5b9e3b006b44e641d197b6b2b8668bf32487f4e6c79d548734e

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.12-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.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cf108b05e71e39f0a3209f29c3e3c6aa9551f47866f53e3cb551d07be9252ad3
MD5 9387bcfe84e2c96d7d048df506caff45
BLAKE2b-256 9b4ba61a4837de5eea64b24608b12e77619e3db71e66d7b274468b0621e03510

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.12-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.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5fc275b368836fc32d7ddca4f33101be46703d50f95e6ed0b3a0d10a19240162
MD5 67f11349fda3624e0f61c89876f739c8
BLAKE2b-256 668d3518dbf395d34d941f3b97b9d6729dc5cb067913ab36b87c0bf1fe2f45a5

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyfrpc-0.2.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 987eff9dcecb6cf78a7e2cacb8ccaabd6a04c642bd1b12766049c2ad8ad7be2d
MD5 29ac1f717c1f92267f2aecfda5617134
BLAKE2b-256 c5aa36b7b1f18d4126dcfea808bf4c2af4c1bd35f6793f6da896bbaa407dc500

See more details on using hashes here.

File details

Details for the file pyfrpc-0.2.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyfrpc-0.2.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 139becdc2bf4aa43563e803d9acd40d3e5d851b1f08b4a55385bb88957130828
MD5 a552d109a3293405d94ec4c16c85e5b7
BLAKE2b-256 0a6adacb5fe748f6dd618e57fe8eddff82057c6b9026306053c021c96bcb502c

See more details on using hashes here.

Supported by

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