Hi all,

Thanks for the suggestions! I have gotten the PR to a working state with UT on top of the latest main (PR).

So it looks to me like this new ufunc should be called `bitwise_count` rather than `bit_count`.

This does sound like a good idea, but would it confuse the users given the scalar version is called `bit_count`? We could change/add an alias for scalar bit_count to `bitwise_count` but that would be different from the Python `bit_count` added in 3.10. Any idea on how to proceed? I'm ok with calling it `bitwise_count` or `bit_count`.

Thanks,
Ganesh

On Thu, Dec 1, 2022 at 3:20 AM Ralf Gommers <ralf.gommers@gmail.com> wrote:


On Fri, Nov 25, 2022 at 9:55 PM Serge Guelton <sergesanspaille@free.fr> wrote:
On Fri, Nov 25, 2022 at 08:09:02PM +0100, Sebastian Berg wrote:
> 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.

It seems like there is enough demand, so +0.5 from me.


> 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.

Technically speaking, bitwise_and, birwise_or, bitwise_xor and bitwise_not
already exist and popcount is widely spread, it already has its compiler builtin
under the name of __builtin_popcount

Those four `bitwise_*` functions also came to mind for me. I'll also add that Python has six bit-wise operators (https://wiki.python.org/moin/BitwiseOperators), and because of that the array API standard implements `bitwise_left_shift` and `bitwise_right_shift` in addition to the four functions that NumPy has.

So it looks to me like this new ufunc should be called `bitwise_count` rather than `bit_count`.

Cheers,
Ralf

_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-leave@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: ganesh3597@gmail.com