'Why doesn't the id of a list change even if the list is moved in memory?

As I know, dynamic arrays (list in Python) move in memory when its size reaches its capacity. And as far as I know the id of an object corresponds to its memory address.

But when appending values to a list many times, its id doesn't change (so it stays in the same place in memory).

Why?

a = []

print(id(a))  # 2539296050560

for i in range(1_000_000):
    a.append(i)

print(id(a))  # 2539296050560


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source