[Numpy-discussion] Re: Add a bit_width function

2025-03-06 Thread Sebastian Berg
Hi all, I am not as such against adding more bit-wise functions. But, I think if we do, we probably need to discuss namespaces. (because adding this is a slippery slope to also adding countr/countl, etc. Unless we can just decide now to add all and those are actually few.) True, `bitwise_` namin

[Numpy-discussion] Re: Add a bit_width function

2025-03-06 Thread Oscar Benjamin via NumPy-Discussion
On Thu, 6 Mar 2025 at 18:12, Carlos Martin wrote: > > Feature request: Add a `bit_width` function to NumPy In Python this is called bit_length: >>> (7).bit_length() 3 ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe sen

[Numpy-discussion] Re: Add a bit_width function

2025-03-06 Thread Carlos Martin
Hi Stefan, It should work on unsigned integer types and use exact computation (not floating-point computations like np.log2). For an example, see https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn. ___ NumPy-Discussion mailing lis

[Numpy-discussion] Re: Add a bit_width function

2025-03-06 Thread Stefan van der Walt via NumPy-Discussion
Hi Carlos, On Thu, Mar 6, 2025, at 10:08, Carlos Martin wrote: > Feature request: Add a `bit_width` function to NumPy's [bit-wise > operations](https://numpy.org/doc/stable/reference/routines.bitwise.html) > that computes the [bit-width](https://en.wikipedia.org/wiki/Bit-width) > (also called b