Skip to main content

Pickle RPC in Python

Very simple RPCs built with sockets & pickle in python. Support numpy as input and output arguments.

Install

pip install picklerpc

Example

Server

import picklerpc
import numpy as np

# function
def numpy_create(shape, dtype):
    return np.arange(np.prod(shape), dtype=dtype).reshape(shape)

def hello():
    return "Hello, world!"

def hello2():
    return None

def add(a, b):
    return a+b

class HelloRPC(object):
    def hello3(self, name):
        return "Hello, %s" % name

# register
server = picklerpc.PickleRPCServer(('localhost', 9102))
server.register_function(numpy_create)
server.register_function(hello)
server.register_function(hello2)
server.register_function(lambda x,y: x-y, 'minus')
server.register_function(add)
server.register_instance(HelloRPC())  #from instance
server.serve_forever()

Client

import picklerpc
import numpy as np

client = picklerpc.PickleRPCClient(('localhost', 9102))

print(client.numpy_create((3,4), dtype=np.float32))
print(client.hello())
print(client.hello3('From Instance'))
print(client.add(np.range(10), 3))
print(client.minus(np.range(10), 3))

Speed compare

The picklerpc is most 10x faster than zerorpc and xmlrpc.

zerorpc xmlrpc picklerpc (mine)
Protocal tcp http tcp
Data Stream - xml pickle
Multiple Client Yes Yes Yes
Data Types Natives Natives Natives + Numpy
Speed (local loop) 683 µs 462 µs 59 µs
Speed (remote) 2.76 ms 4.64 ms 0.54 ms

Reference

Thanks https://github.com/TarasZhere/RPC

Metadata

Release files for picklerpc 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for picklerpc 0.1.0
File Size Uploaded Provenance
picklerpc-0.1.0.tar.gz 3.2 kB Without provenance Details

Release files / picklerpc-0.1.0.tar.gz

Download URL picklerpc-0.1.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b61147b177d2a6e9ff2cfb0cfa5cd2aa185bc9905d60ff91e5f2c96cfe574d48
BLAKE2b-256 checksum
How to use checksums
68eb675d7660e38ca606c81f6433e9982d73a2b8a612d2dc35ed589c7f9ac118
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Security for picklerpc 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page