RE: scalable bottleneck

2019-04-04 Thread Schachner, Joseph
If you are using Python 3, range does not create at list, it is a generator. If you're using Python 2.x, use xrange instead of range. xrange is a generator. In Python 3 there is no xrange, they just made range the generator. --- Joseph S. -Original Message- From: Sayth Renshaw Se

Re: scalable bottleneck

2019-04-03 Thread Sayth Renshaw
On Thursday, 4 April 2019 10:51:35 UTC+11, Paul Rubin wrote: > Sayth Renshaw writes: > > for x in range ( max_root ): > > 1) Do you see a memory bottleneck here? If so, what is it? > > 2) Can you think of a way to fix the memory bottleneck? > > In Python 2, range(n) creates a list in memory.

Re: scalable bottleneck

2019-04-03 Thread MRAB
On 2019-04-03 22:42, Sayth Renshaw wrote: In an email, I received this question as part of a newsletter. def fetch_squares ( max_root ): squares = [] for x in range ( max_root ): squares . append (x **2) return squares MAX = 5 for square in fetch_squares (MAX ): d