Re:Show HN: Refurb – A tool for refurbishing and modernizing...
by cmcconomy on Wednesday September 28, 2022 @10:29AM
(#33008388)
right, python caches ints from -5 to 256 as singletons, so id(x) for those numbers is constant.
whereas each time you run id() on a number outside that range you will get a different id as a new object is instantiated
For example you can see that by adding a large power of two to the numbers you can see that they are sorted by the remainder (as it seems that the default number of buckets is a power of two):