r/cpp • • Jun 21 '26

Pymetabind: Writing pybind11 bindings with C++26 reflections

https://codeberg.org/bstaletic/pymetabind/
81 Upvotes

26 comments sorted by

View all comments

Show parent comment

1

u/13steinj Jun 22 '26

My own project's benchmarks took a considerable hit after migrating to nanobind

This is surprising to hear. I got a little "into it" with the author/maintainer because I felt his benchmark results were at best misleading and at worst intentionally done in a way to favor nanobind, to more clearly beat out Cython... but I can't imagine a use case where you'd lose performance going from pybind to nanobind.

1

u/_bstaletic Jun 22 '26

I may have been too terse with that statement.

In my case, part of the benchmark suite were purely c++ benchmarks and another part of the suite dealt with py::lists. To my surprise all benchmarks were affected equally. I do compile the bindings as part of the rest of the project, so everything gets compiled with -O3, against nanobind's recommendations. I think I've messed with NOMINSIZE argument of nanobind_add_module(), but it's been a long time, so don't take my word for it.

 

Yes, I was surprised by the numbers I saw as well. nanobind definitely did make some improvements that I was convinced would make it beat pybind11.