how to improve this cycle (extracting data from structured array)?

Alexzive zasaconsulting at
Thu Feb 11 12:44:55 CET 2010

Hello guys,

I am just wondering if there is a quick way to improve this algorithm
[N is a structured array which hold info about the nodes n of a finite
element mesh, and n is about 300.000). I need to extract info from N
and put it in to a 3*n matrix NN which I reshape then with numpy. I
think to "append" is quite unefficient:

N = odb.rootAssembly.instances['PART-1-1'].nodes


 #auxsiliar vector
for i in range(len(N)):

    B[0] = N[i].label

    B[1] = N[i].coordinates[0]

    B[2] = N[i].coordinates[1]

    NN = append(NN,B)


Many Thanks in advance!

More information about the Python-list mailing list