RE: scalable bottleneck

2019-04-04 Thread Schachner, Joseph
nshaw Sent: Wednesday, April 3, 2019 5:42 PM To: python-list@python.org Subject: scalable bottleneck 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

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

scalable bottleneck

2019-04-03 Thread Sayth Renshaw
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 ): do_something_with ( square ) 1) Do you see a memo