Python has enumerate()
to iterate over objects with an index.I doubt that interpreters create a lot of int objects for the sole purpose of keeping track of where things are. The PEP page says the following, but I do not really understand what is going on under the hood:
It provides all iterables with the same advantage that iteritems() affords to dictionaries -- a compact, readable, reliable index notation.
So what is the magic here?