Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/python/src/python.ts>Callback

🐍 Python interpreter bindings for Deno and Bun.
Go to Latest
class Callback
import { Callback } from "https://deno.land/x/python@0.4.2/src/python.ts";

Wraps a JS function into Python callback which can be passed to Python land. It must be destroyed explicitly to free up resources on Rust-side.

Example:

// Creating
const add = new Callback((_, a: number, b: number) => {
  return a + b;
});
// or
const add = new Callback((kw: { a: number, b: number }) => {
  return kw.a + kw.b;
});

// Usage
some_python_func(add);

// Destroy
add.destroy();