[Numpy-discussion] On Numexpr and uint64 type

Francesc Altet faltet@carabos....
Mon Mar 10 12:08:41 CDT 2008


In order to allow in-kernel queries in PyTables (www.pytables.org) work 
with unsigned 64-bit integers, we would like to see uint64 support in 
Numexpr (http://code.google.com/p/numexpr/).

To do this, we have to decide first how uint64 interacts with other 
types.  For example, which should be the outcome of:

numpy.array([1], 'int64') / numpy.array([2], 'uint64')

Basically, there are a couple of possibilities:

1) To follow the behaviour of NumPy and upcast both operands to float64 
and do the operation.  That is:

In [21]: numpy.array([1], 'int64') / numpy.array([2], 'uint64')
Out[21]: array([ 0.5])

2) Implement support for uint64 as a non-upcastable type, so that one 
cannot merge uint64 operands with other types.  That is:

In [21]: numpy.array([1], 'int64') / numpy.array([2], 'uint64')
Out[21]: TypeError: unsupported operand type(s) for /: 'int64' 
and 'uint64'

Solution 1) is appealing because is how NumPy works, but I don't 
personally like the upcasting to float64.  First of all, because you 
transparently convert numbers potentially loosing the least significant 
digits.  Second, because an operation between integers gives a float as 
a result, and this is different for typical programming languages.

Solution 2) addresses shortcomings of solution 1), but introduces the 
problem that can only operate in conjunction with other uint64 
operands, making it practically an 'isolated' type (much like a string 

We are mostly inclined to implement 2) behaviour, but before proceed, 
I'd like to know what other people think about this.


>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data

More information about the Numpy-discussion mailing list