Thanks for bringing this up again. The Python method exists and it seems like relatively basic functionality.
Overall, I am slightly in favor of adding the ufunc. So if nobody voices an opinion that it doesn't seem a good fit for NumPy, I would be happy to move forward with it. - Sebastian PS: One of my main concern would be if we were to add many bitwise functions, in which case a `bitwise` namespace might be nice. But I am not convinced that should stop us here. On Thu, 2022-11-24 at 15:56 +0000, Doug Turnbull wrote: > ๐Long time numpy user, and big fan of all your work > > TL; DR - there's a `bit_count` method on numpy scalars, and Python > ints, I'm advocating for a `ufunc` `bit_count` as has been > implemented in this PR: > > https://github.com/numpy/numpy/pull/21429 > > A number of people have requested this as a numpy feature and there's > a lot of great discussion at this issue > > https://github.com/numpy/numpy/issues/16325 > > A bit count comes up in certain similarity situations (like hamming > distance). This involves an xor with numpy arrays and a bit count, > where the bit count is currently the bottleneck by a few orders of > magnitude in my local benchmarking. Currently there's a number of not > particularly fast, workarounds for doing this with numpy arrays, like > the bit-twiddling solutions here > > https://stackoverflow.com/a/68943135/8123 > https://stackoverflow.com/a/109025/8123 > > So I'd love to be able to continue the work of bit_count -> numpy > array ufunc to get performance gains at the array level ๐ > _______________________________________________ > NumPy-Discussion mailing list -- numpy-discussion@python.org > To unsubscribe send an email to numpy-discussion-le...@python.org > https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ > Member address: sebast...@sipsolutions.net _______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com