[Numpy-discussion] The risks of empty()

Bock, Oliver BGI SYD Oliver.Bock at barclaysglobal.com
Tue Jan 2 18:48:19 EST 2007

Some of my arrays are not fully populated.  (I separately record which
entries are valid.)  I want to use numpy.empty() to speed up the
creation of these arrays, but I'm worried about what will happen if I
apply operations to the entire contents of these arrays.  E.g.

a + b

I care about the results where valid entries align, but not otherwise.
Given that numpy.empty() creates an ndarray using whatever junk it finds
on the heap, it seems to me that there is the possibility that this
could include bit patterns that are not valid floating point
representations, which might raise floating point exceptions if used in
operations like the one above (if they are "signalling" NaNs).  Will
this be a problem, or will the results of operations on invalid floating
point numbers yield NaN?

Or to put it another way: do I need to ensure that array data is
initialised before using it?

This message and any attachments are confidential, proprietary, and may be privileged.  If this message was misdirected, Barclays Global Investors (BGI) does not waive any confidentiality or privilege.  If you are not the intended recipient, please notify us immediately and destroy the message without disclosing its contents to anyone.  Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.  The views and opinions expressed in this e-mail message are the author's own and may not reflect the views and opinions of BGI, unless the author is authorized by BGI to express such views or opinions on its behalf.  All email sent to or from this address is subject to electronic storage and review by BGI.  Although BGI operates anti-virus programs, it does not accept responsibility for any damage whatsoever caused by viruses being passed.

More information about the NumPy-Discussion mailing list