Principle:Ray project Ray Cross Language Function Descriptors
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Computing, Cross_Language_Interop |
| Last Updated | 2026-02-13 17:00 GMT |
Overview
A descriptor mechanism for referencing functions and actor classes defined in foreign programming languages by their module, class, and function names.
Description
Cross-Language Function Descriptors are lightweight Java objects that describe a target function or actor class in Python or C++. They encapsulate the metadata needed to locate the function at runtime — module name, function name, class name, and expected return type. The descriptors are translated into PyFunctionDescriptor or CppFunctionDescriptor at task submission time, which the Raylet uses to route the task to the appropriate language worker.
Four descriptor types are provided:
- PyFunction — Python function reference
- CppFunction — C++ function reference
- PyActorClass — Python actor class reference
- CppActorClass — C++ actor class reference
Usage
Create descriptors using the static .of() factory methods. Pass descriptors to Ray.task() or Ray.actor() for cross-language task submission.
Theoretical Basis
Function descriptors implement a foreign function interface (FFI) pattern. Rather than importing foreign code into the current language runtime, descriptors provide a symbolic reference that is resolved at task dispatch time by the appropriate language worker.