[Numpy-discussion] .bytes

Robert Kern robert.kern at gmail.com
Mon Oct 15 12:42:53 EDT 2007


Yves Revaz wrote:
> Nadav Horesh wrote:
> 
>> array(1, dtype=float32).itemsize
>>
> ok, it will work fine for my purpose.
> In numpy, is there any reason to supress the attribute .bytes from the 
> type object itself ?
> Is it simply because the native python types (int, float, complex, etc.) 
> do not have this attribute ?

The problem is that the instances of the scalar types do have the itemsize
attribute. The implementation of type objects is such that the type object will
also have that attribute, but it will be a stub:

In [15]: float64.itemsize
Out[15]: <attribute 'itemsize' of 'numpy.generic' objects>

A more straightforward way to get the itemsize is this:

In [17]: dtype(float64).itemsize
Out[17]: 8

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list