By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,050 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,050 IT Pros & Developers. It's quick & easy.

looping over arrays in numarray/numeric

P: n/a
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?

Sep 9 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
proof wrote:
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
rk***@ucsd.edu

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

Sep 9 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.