if the last section' for loop looks like the list comprehension expression introduced earlierit shouldboth are really general iteration tools in factboth will work on any iterable object that follows the iteration protocol--pervasive ideas in python that underlie all its iteration tools in nutshellan object is iterable if it is either physically stored sequence in memoryor an object that generates one item at time in the context of an iteration operation -- sort of "virtualsequence more formallyboth types of objects are considered iterable because they support the iteration protocol--they respond to the iter call with an object that advances in response to next calls and raises an exception when finished producing values the generator comprehension expression we saw earlier is such an objectits values aren' stored in memory all at oncebut are produced as requestedusually by iteration tools python file objects similarly iterate line by line when used by an iteration toolfile content isn' in listit' fetched on demand both are iterable objects in python- category that expands in to include core tools like range and map 'll have more to say about the iteration protocol later in this book for nowkeep in mind that every python tool that scans an object from left to right uses the iteration protocol this is why the sorted call used in the prior section works on the dictionary directly--we don' have to call the keys method to get sequence because dictionaries are iterable objectswith next that returns successive keys it may also help you to see that any list comprehension expressionsuch as this onewhich computes the squares of list of numberssquares [ * for in [ ]squares [ can always be coded as an equivalent for loop that builds the result list manually by appending as it goessquares [for in [ ]squares append( * this is what list comprehension does both run the iteration protocol internally squares [ both tools leverage the iteration protocol internally and produce the same result the list comprehensionthoughand related functional programming tools like map and filterwill often run faster than for loop today on some types of code (perhaps even twice as fast)-- property that could matter in your programs for large data sets having said thatthoughi should point out that performance measures are tricky business in python because it optimizes so muchand they may vary from release to release introducing python object types