Mirror_bridge – C++ reflection for generating Python/JS/Lua bindings

Python devs cheer one-click C++ speed as skeptics grill the toolchain

TLDR: Mirror Bridge lets you call fast C++ from Python with one command using reflection. Fans love ditching glue code, while skeptics debate an experimental compiler and say speedups only shine when you move big loops into C++.

Mirror Bridge promises the dream: write your hot code in C++, press a button, and use it from Python like magic. The crowd went wild for the idea of skipping glue code, with a_t48 admitting they were “nerd sniped” and cheering that the author “moved the loop” to show where real speed lives. Translation for non-nerds: calling C++ from Python is fast, but crossing that language border has a toll; you win big when you do more work per border crossing.

Then came the drama. dsp_person raised the eyebrow of the week: the tool depends on an experimental Clang compiler fork from Bloomberg to get C++ reflection (the feature that lets the tool auto-discover your classes). The spicy question: can you use that funky compiler only to generate bindings, then build with a normal one? The vibe: “Love the idea, not the toolchain chaos.”

Meanwhile, kvemkon pulled the classic Actually… card, pointing out the write-up skims past nanobind (the binding layer under the hood) and quibbling that Python objects for fixed C++ classes can skip slow dictionary lookups via slots. The comments turned into a meme factory: the Ferrari-at-every-stoplight analogy, jokes about the “GIL” (Global Interpreter Lock, a one-at-a-time gatekeeper), and “just move your loop” becoming the new speed gospel. Verdict: hype meets homework, and the community is here for both.

Key Points

  • Mirror Bridge uses C++26 reflection to auto-generate language bindings, removing the need for manual binding code.
  • A Vec3 example shows generating a Python module with a single command and invoking C++ methods from Python.
  • Benchmark on an M3 Max MacBook Pro reports Python: 0.11s vs C++ via Mirror Bridge: 0.04s for 1,000,000 dot() calls (2.9x speedup).
  • The article details cross-language overhead: method lookup, boxing, type checks, GIL management, result conversion, and return.
  • C++ can be faster because it operates on native types with compile-time checks, while Python performs runtime lookups and object handling.

Hottest takes

“I feel a little bit nerd sniped … I’m super excited to use this” — a_t48
“Possible to use that C++26 compiler just to do code generation…?” — dsp_person
“I’m missing nanobind here.” — kvemkon
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.