I have to write a paper for college and therefore analyse the memory consumption of python and mojo lists with integers.
While experimenting I noticed that if I use the same integers Python always only generates one objects, while the others are just references to that object.
I read this is called interning, but I only find articles saying its just for the interval from -5 to 256.
I tested it in Python 3.10.13 and 3.12..7 :
Regardless if I use 1 or 1000000 as a value for my integer the interning behaviour is always done.
An example speaks louder than words:
>>> x = 1001
>>> y = 1001
>>> x is y
True
https://luminousmen.com/post/interning-in-cpython?utm_source=chatgpt.com
Also are there some papers or official python ressources explainig that, so I can quote them in my paper