4 ms·
> To this day I have the nervous tick of initializing arrays with zeros even in numpy. I dunno - I wouldn’t call that a nervous tick. If you know or have a goo
by rufius 7y ago
> To this day I have the nervous tick of initializing arrays with zeros even in numpy.
I dunno - I wouldn’t call that a nervous tick. If you know or have a good idea of how much memory you need, then it only seems polite to let the runtime/OS know ahead of time.
I think of it like RSVP’ing to a dinner party. Host is very appreciative when they know how many people they’re serving.
- bobbylarrybobby 7y agoIt is a tic — if you plan to fill the array anyway there’s no need to set its values on initialization
- sgillen 7y agoNo but in dynamic languages just making the array before hand can greatly increase efficiency.