Mirror_bridge – C++ reflection for generating Python/JS/Lua bindings
chico.dev·4d·
Discuss: Hacker News
🦀Rust Macros
Preview
Report Post

You have a Python codebase. Thousands of lines. It works. Your team knows it. Your tests cover it. Your CI/CD deploys it.

But there’s this one function. It shows up in every profile. It’s eating 80% of your runtime. You know it would be faster in C++.

The traditional answer? Rewrite it in C++, then spend sometime writing pybind11 boilerplate to call it from Python. Or just… don’t bother.

Mirror Bridge is a third option: write C++, run one command, done.

The Setup

Let’s say you have a simple operation - a dot product:

// vec3.hpp
struct Vec3 {
double x, y, z;

Vec3(double x, double y, double z) : x(x), y(y), z(z) {}

double dot(const Vec3& other) const {
return x * other.x + y * other.y + z * other.z;
}

// Compute the magnitude (norm) of the vector
do...

Similar Posts

Loading similar posts...