Do list comprehensions in Python reduce in a memory efficient manner?

I am a beginner at Python, and this is my first post, so don't be too harsh :). I've been playing around with Python lately and was wondering if something like

max([x for x in range(25)]) 

would result in Python first creating a list of all the elements and then finding the max, resulting in O(2n) time, or it would keep track of the max as it was iterating for Θ(n). Also, since range differs in Python3 (being a iterable), would that make it different than in Python2?

8
задан eumiro 18 March 2011 в 08:51
поделиться