A high-performance, peer-to-peer RPC library that makes remote objects feel local. Built on top of Yamux multiplexing and Python's __getattr__ magic, it enables seamless bi-directional interaction between processes with support for callbacks, distributed garbage collection, and transparent async proxying.
- Peer-to-Peer Architecture: No strict client/server distinction — both sides can import and export objects, enabling true bi-directional communication.
- "Local-Feeling" API: Intercepts property access, method calls, and item access using
__getattr__and__getitem__, making remote objects behave like local ones. - Distributed Garbage Collection: Automatically manages remote object lifecycles using
weakrefand a reference counting protocol. - Bi-Directional Callbacks: Pass functions and objects as arguments — they are automatically registered and hydrated as proxies on the other side.
- Instruction Batching: Chains of property accesses and method calls are accumulated and sent as a single
EXECUTEinstruction for efficiency. - Stream Multiplexing: Uses Yamux to multiplex concurrent operations over a single connection.
pip install proxyablesServer (Exporting an object):
from proxyables import Proxyable
class API:
def echo(self, msg: str) -> str:
return f"echo {msg}"
def compute(self, a: int, b: int) -> int:
return a + b
# stream is any asyncio duplex stream
exported = await Proxyable.Export(API(), stream)Client (Importing the object):
from proxyables import Proxyable
proxy = await Proxyable.ImportFrom(stream)
# Usage - feels completely local!
result = await proxy.echo("hello") # "echo hello"
result = await proxy.compute(10, 20) # 30- Proxy Layer:
ProxyCursorwraps remote objects, accumulating instructions on property access and method calls. - Instruction Protocol: Operations (get, apply, etc.) are serialized into
ProxyInstructionmessages using MessagePack. - Transport: Uses Yamux to multiplex concurrent operations over a single connection (TCP, Unix socket, stdio, etc.).
- Reference Management: An
ObjectRegistrytracks local objects passed by reference with automatic cleanup viaweakref.
MIT