Quantcast
Viewing latest article 6
Browse Latest Browse All 9

Answer by Srinivas Reddy Thatiparthy for identifying objects, why does the returned value from id(...) change?

Python caches immutable objects(read integers and tuples..) - which is why they are immutableand saves memory if u reference the same immutable in manyplaces. So small integers, empty tuples and such are actuallycached in Python runtime, so you keep getting back the same objectand hence the same id.

Try this for the list, you don't get the same id.


Viewing latest article 6
Browse Latest Browse All 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>