====== Lazy vs Eager evaluation ====== Python generally uses an eager evaluation (in contrary to [[cs_lang:haskell|Haskell]]) but for example with Python 3 the range() function returns a special range object which computes elements of the list on demand. >>> r = range(10) >>> print(r) range(0, 10) >>> print(r[3]) 3 This was not the case with Python 2 (without iterators): >>> r = range(10) >>> print r [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> print r[3] 3 Lazy evaluation saves execution time for large ranges.