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

Christopher Hanley chanley at stsci.edu
Wed Nov 2 08:58:46 CST 2005


Travis Oliphant wrote:
> 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

Thank you Travis,

I like this solution much more than going through the multiarray module.

Chris




More information about the Scipy-dev mailing list