insertion order

The order in which items were added to a collection, which Python dicts preserve when you iterate over them.

In more detail

Iterating over a dict yields keys in the order they were first inserted; this has been part of the language since Python 3.7. Updating an existing key keeps its position, while deleting and re-adding moves it to the end. Sets make no such promise, so their iteration order should never be relied on.

Related terms

Taught in

References