I really like SQL. Sure, the language has warts but the ability to concisely represent WHAT you want, not HOW you want it, makes it very readable once you understand the simple constructs and how to properly design tables and indexes (not very hard). For example, consider the problem of finding the second largest value in a set. In SQL, I'd do something like: SELECT MAX( col ) FROM table WHERE col It's pretty readabl…
FWIW here's a very similar Python version: max(col for col in table if col a fun one is this: first, second = max(permutations(table), 2) although its semantics are slightly different (if the maximum of the table is duplicated, it'll be returned for both slots) or using heapq which notaddicted mentioned.
In your example, if you replace max() with a function that prints something, you'll see it's executed for each value in 'table', which is extremely inefficient. This happens because Python can't guarantee that max() will return the same each time.
Similarly, while in a side-effect free context the runtime could, for example, slice 'table', perform the work using multiple concurrent threads and then join the result, Python has to guarantee that the execution is done sequentially, since a change in order could affect the result.
Unlike in SQL, in Python you're always telling it HOW you want it done.