[SciPy-user] object_arrtype addition error

Travis Oliphant oliphant.travis at ieee.org
Tue Nov 29 13:06:30 CST 2005


Chris Fonnesbeck wrote:

>On 11/29/05, Ryan Krauss <ryanlists at gmail.com> wrote:
>  
>
>>But how can Python know how much space to save for the array if it
>>doesn't know the data type?
>>
>>    
>>
>
>I wouldnt argue with you except that I was able to do this in Numeric.
>I could initialize an array to:
>
>foo = array([None]*1000)
>
>Then populate it with whatever I like afterwards.
>
>  
>
Yes, you could do this, just as you can with scipy_core.  But, Numeric 
was always dealing with an object array.   It's just that the object 
returned was a Python float.  Now, selection from object arrays returns 
a "wrapped" object (that's what an object scalar is).  In your case it's 
a "wrapped" Python float that allows the scalar to have all the methods 
and attributes of arrays. 

So, you have always been using object arrays.  That's fine, if you 
recognize that object arrays can be a little slower and consume more 
memory.  It all depends on what you do with them. 

The only thing that's changed is what gets returned from an object 
array.  The reason for the change is to provide (method and attribute) 
consistency between scalar elements of an array and the array itself.  

-Travis



More information about the SciPy-user mailing list