looping over arrays in numarray/numeric

P

proof

a = range(1000000)
b = [a] * 3

b[1] = [k + i for k, i in zip(b[1], b[2])]

This is rather slow in python and I thought that kind of things should
be written using numeric or numarray. I tried to read trough manuals
but it didn't help me. So how is this done using numeric or numarray?
 
R

Robert Kern

proof said:
a = range(1000000)
b = [a] * 3

b[1] = [k + i for k, i in zip(b[1], b[2])]

This is rather slow in python and I thought that kind of things should
be written using numeric or numarray. I tried to read trough manuals
but it didn't help me. So how is this done using numeric or numarray?

In [1]: from Numeric import *

In [2]: a = arange(1000000)

In [3]: b = array((a,a,a))

In [4]: b[1] += b[2]

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top