Hashing enums #105
-
While converting pybind11 bindings for an enumeration type, I noticed the following:
When adding a
Can you tell me if you plan to support hashing enums, like pybind11 does, and/or tell me if and how I can add my own |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @mnijhuis-tos -- that's a good catch. Could you create a PR that implements the hashing function in the libnanobind component? (specifically, that would be in the file |
Beta Was this translation helpful? Give feedback.
Hi @mnijhuis-tos -- that's a good catch. Could you create a PR that implements the hashing function in the libnanobind component? (specifically, that would be in the file
src/nb_enum.cpp
). Instead of using.def("__hash__", ...)
would do this at a lower level by providing thePy_tp_hash
type slot in this file. Hopefully it's clear enough if you look at the other code there.