Why do integers starting from 257 onwards not return the same id? /u/Sulai2 Python Education

x = 257 y = 257 print(id(x)) print(id(y)) output: 1846763545888 1846763545888 

I was reading about memory allocation. Shouldn’t their IDs be different, since Python creates a new object for integers greater than 257?

submitted by /u/Sulai2
[link] [comments]

​r/learnpython x = 257 y = 257 print(id(x)) print(id(y)) output: 1846763545888 1846763545888 I was reading about memory allocation. Shouldn’t their IDs be different, since Python creates a new object for integers greater than 257? submitted by /u/Sulai2 [link] [comments] 

x = 257 y = 257 print(id(x)) print(id(y)) output: 1846763545888 1846763545888 

I was reading about memory allocation. Shouldn’t their IDs be different, since Python creates a new object for integers greater than 257?

submitted by /u/Sulai2
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *