Skip to main content
Module

x/python/ipy.ts>Callback

🐍 Python interpreter bindings for Deno and Bun.
Latest
class Callback
import { Callback } from "https://deno.land/x/python@0.4.3/ipy.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();