On Mon, 2021-08-02 at 13:10 -0700, Stefan van der Walt wrote: > On Mon, Aug 2, 2021, at 10:50, Sebastian Berg wrote: > > * Should `np.ndarray.bit_count()` exist? I tend against this; > > but we should have it on (integer) scalars to mirror the > > Python `int`. > > Should `np.bit_count` exist? Having it on the int* types may be > sufficient.
Right, we could add it only to the integer scalars mostly for Python compatibility. The PR suggests to create a ufunc to make the feature available to typical NumPy code (allow using it with arrays). > > > * The return value is currently the same type as the input. That > > means that: `np.bit_count(uint8)` returns the count as `uint8` > > while `np.bit_count(int32)` returns it as `int32`, etc. > > What is the max value of the count? 64? If so it can go in a uint8. Yes, uint8 would even work for 128 bit integers. I was a bit unsure about this, since we rarely create non-default integer arrays unless prompted, but it is a good option as well. Cheers, Sebastian > > Stéfan > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@python.org > https://mail.python.org/mailman/listinfo/numpy-discussion
signature.asc
Description: This is a digitally signed message part
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion