20250625

I could not sleep well because I had many meetings last evening, and it stimulated my nerves.

In [1]: a, b = 'foobar', 'barbaz'

In [2]: a[:3] is b[:3]
Out[2]: False

In [3]: id(a[:3]) == id(b[:3])
Out[3]: True

In [4]: id(a[:3])
Out[4]: 4347335216

In [5]: id(b[:3])
Out[5]: 4347019760

StackOverflow - Why does id({}) == id({}) and id([]) == id([]) in CPython? [duplicated]

When evaluating id(a[:3]) == id(b[:3]), the first a[:3] seems to be garbage collected before evaluating id(b[:3]), and b[:3] seems to use the same address (with CPython).


TODO:


index 20250624 20250626