On 10/25/13 7:55 AM, Mark Janssen wrote:
On Thu, Oct 24, 2013 at 8:40 PM, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
On 22/10/2013 18:37, Oscar Benjamin wrote:
OTOH why in particular would you want to initialise them with zeros? I
often initialise arrays to nan which is useful for debugging.
Is this some kind of joke?  What has this list become?


It's a useful debugging technique to initialize memory to distinctive values that should never occur in real data. Perhaps it better to say, "pre-initialize". If the program is working correctly, then that data will be written over with actual initial values, and you'll never see the distinctive values. But if your program does encounter one of those values, it's clear that there's a bug that needs to be fixed. Additionally, if you have a number of different distinctive values, then the actual value encountered provides a clue as to what might have gone wrong.

In an array of floats, initializing to NaN would be very useful, since NaNs propagate through calculations, or raise exceptions.

--Ned.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to