[Numpy-discussion] Database with Nulls to Numpy Structure

Christopher Barker Chris.Barker at noaa.gov
Fri Oct 2 15:33:35 EDT 2009


Mark Janikas wrote:
> So, do I use lists and 
> append then create the arrays… Or do I fill up the pre-allocated “empty” 
> arrays and slice off the ends?  Thoughts?  Thanks much…

Either will work. I think the decision would be based on how many Null 
records you expect -- if it's a small fraction then go ahead and 
pre-allocate the array, if it's a large fraction, then you might want to 
go with a list.

Note: you may be able to use arr.resize() to chop it off at the end.

The list method has the downside of using more memory, and being a bit 
slower, which may be mitigated if there are lots of null records.

See an upcoming email of mine for another option...

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list