[Python] What is the implementation detail for enumerate?

Discussão em 'Python' iniciado por Stack, Setembro 2, 2025.

  1. Stack

    Stack Membro Participativo

    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?

    Continue reading...

Compartilhe esta Página