[SciPy-dev] adding new attribute to data type objects

Travis Oliphant oliphant at ee.byu.edu
Tue Nov 1 17:13:54 CST 2005


Christopher Hanley wrote:

>Hi Travis,
>
>In numarray a user is able to say the following in order to get the size
>of a data type in bytes:
>  
>

Chris (and everyone else):

I've just added an nbytes dictionary to scipy core.

You can now say

scipy.nbytes[<any recognized type alias>]

and get the number of bytes

thus

scipy.nbytes['d']
scipy.nbytes[scipy.float_]
scipy.nbytes[float]
scipy.nbytes[scipy.float64]
scipy.nbytes[scipy.Float64]

all return the same thing:  64

There is also a new nbytes attribute of ndarray's that does the itemsize 
* size multiplication for you to give the number of bytes in the array.

-Travis




More information about the Scipy-dev mailing list