question on list comprehensions
Roberto Antonio Ferreira De Almeida
roberto at dealmeida.net
Thu Oct 14 17:02:52 CEST 2004
Darren Dale wrote:
> I need to replace the following loop with a list comprehension:
> for i in arange(10000):
res = (10000 * (10000-1))/2.0 ;-)
> In practice, res is a complex 2D numarray. For this reason, the regular
> output of a list comprehension will not work: constructing a list of every
> intermediate result will result in huge hits in speed and memory.
Why do you *need* to replace the for loop with a listcomp? Could you
give more details about what you're doing with the complex array?
More information about the Python-list