Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update benchmark Python bindings for nanobind 2.0, and update to nano…
…bind 2.0. (#1817) Incorporates the nanobind_bazel change from #1795. nanobind 2.0 reworked the nanobind::enum_ class so it uses a real Python enum or intenum rather than its previous hand-rolled implementation. https://nanobind.readthedocs.io/en/latest/changelog.html#version-2-0-0-may-23-2024 As a consequence of that change, nanobind now checks when casting an integer to a enum value that the integer corresponds to a valid enum. Counter::Flags is a bitmask, and many combinations are not valid enum members. This change: a) sets nb::is_arithmetic(), which means Counter::Flags becomes an IntEnum that can be freely cast to an integer. b) defines the | operator for flags to return an integer, not an enum, avoiding the error. c) changes Counter's constructor to accept an int, not a Counter::Flags enum. Since Counter::Flags is an IntEnum now, it can be freely coerced to an int. If wjakob/nanobind#599 is merged into nanobind, then we can perhaps use a flag enum here instead.
- Loading branch information