minus-squareJATothrim_v2@programming.devtoPython@programming.dev•Python's Data Model Explained through Visualizationlinkfedilinkarrow-up7·8 days ago For immutable types it is the same though. The most twisted thing I learned is that all ints below a fixed limit share the same id() result, so >>> x = 1 >>> id(x) 135993914337648 >>> y = 1 >>> id(y) 135993914337648 But then suddenly: >>> x = 1000000 >>> id(x) 135993893250992 >>> y = 1000000 >>> id(y) 135993893251056 Using id() as a key in dict() may get you into trouble. linkfedilink
The most twisted thing I learned is that all
ints below a fixed limit share the sameid()result, so>>> x = 1 >>> id(x) 135993914337648 >>> y = 1 >>> id(y) 135993914337648But then suddenly:
>>> x = 1000000 >>> id(x) 135993893250992 >>> y = 1000000 >>> id(y) 135993893251056Using
id()as a key indict()may get you into trouble.