[Numpy-discussion] Array and vector initialization good practice

Dinesh B Vadhia dineshbvadhia@hotmail....
Wed Jun 18 20:08:32 CDT 2008

Say, there are two initialized numpy arrays:

A = numpy.blah
B = numpy.blah.blah

With, C = A*d + B*e which doesn't have to be initialized beforehand (as A and B are and so are d and e)

Now, place this in a function ie.

def havingFun(d, e)
    C = A*d + B*e
    return C

The main program calls havingFun(d, e) continuously with new vectors d and e each time (A and B do not change).

Assume that A, B, C, d, e are all very large (>100,000 rows and/or columns).  

In the first call to havingFun, C is created.  In the next call, does Python/Numpy/Scipy have C available to overwrite it or does it create a new C (having deleted the previous C)?

Wrt to efficiency and performance does it matter if C is initialized beforehand or not?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080618/788cd647/attachment.html 

More information about the Numpy-discussion mailing list