[Numpy-discussion] profile reveals calls to astype()

Curzio Basso curzio.basso at unibas.ch
Thu Apr 7 09:58:40 CDT 2005


Hi all,

I have a problem trying to profile a program using numarray, maybe someone with more experience can 
give me a hint...

basically, the program I am profiling has a function like this:

foo():
   # some code
   # a call to astype()
   for i in xrange(N):
     # some other code and NO explicit call to astype()

the problem is that when I print the 'callees' of foo(), astype() gets listed with an occurrence of 
N+1, as if it was called inside the loop.
So now the first doubt I have is that astype() gets listed because called from some function called 
by foo(), even if this should not happen. Here is the list of numarray functions called in foo()

Function                 called...
                           generic.py:651(getshape)(14)    0.070
                           generic.py:918(reshape)(2)    0.000
                           generic.py:1013(where)(2)    0.050
                           generic.py:1069(concatenate)(2)    4.270
                           morphology.py:150(binary_erosion)(2)    0.070
                           numarraycore.py:698(__del__)(120032)    3.240
                           numarraycore.py:817(astype)(12002)   37.290
                           numarraycore.py:857(is_c_array)(36000)   10.450
                           numarraycore.py:878(type)(4)    0.000
                           numarraycore.py:964(__mul__)(12)    0.340
                           numarraycore.py:981(__div__)(8)    0.010
                           numarraycore.py:1068(__pow__)(8)    0.000
                           numarraycore.py:1180(__imul__)(12000)    0.930
                           numarraycore.py:1250(__eq__)(2)    0.080
                           numarraycore.py:1400(zeros)(54)    0.060
                           numarraycore.py:1409(ones)(8)    0.020

The second thing I can think of is that astype() is implicitly called by some conversion. Can this be?

curzio




More information about the Numpy-discussion mailing list