[Numpy-discussion] proposal on ufunc bit ops

Charles R Harris charlesr.harris at gmail.com
Wed May 28 13:55:34 EDT 2008


Hi All,

I would like to propose that the bit_ops preserve the length of the relevant
types. Currently we have:

In [1]: ones(1,dtype=int8) & ones(1,dtype=uint8)
Out[1]: array([1], dtype=int16)

In [3]: ones(1,dtype=int64) & ones(1,dtype=uint64)
Out[3]: array([1], dtype=object)


Note the increased size in the first case and the return of a Python long
integer object in the second. As all the high order bits will be zeroed in
any case when the smaller elements are sign extended, I propose that in
these mixed cases an unsigned type be returned of the same size as the
largest input size. I think this conforms with the rule of least surprise.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080528/908f70ff/attachment.html>


More information about the NumPy-Discussion mailing list