jmalkin commented on issue #20: URL: https://github.com/apache/datasketches-python/issues/20#issuecomment-1853121324
Thought I hit a blocker on this, but `std::variant` to the rescue. Pybind11 is fairly aggressive at casting things to a numpy array whereas nanobind is less so. In the interest of maximizing API compatibility, I was trying to continue to let vector_of_kll specify indices as a single value, a python list, or an actual array. If I accept a generic `object` it works, but I couldn't find a way to construct an `ndarray` from the object. Using `std::variant` lets me constrain the types of inputs and avoid an explosion of polymorphic types while letting me extract the values as the proper type, no casting needed. The one cost I've found is that it doesn't seem to play nicely with `std::reference_wrapper`, so I'll need to copy objects it seems. With luck that's mostly just incrementing a reference but I didn't look at internals. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
