+ 1
size of an object
https://code.sololearn.com/c4Zhhx62Fu32/#py why in both case am i getting the same space allocated ??. Shouldn't it be different ?? or did I understood it wrong??. Do explain??
3 Answers
+ 2
Mani 2 objects with non-overlapping lifetime can have same Id.
+ 2
you are assigning two variables to the class itself. that is why the values turn out the same.
instead you should assign the object of the class like this
c1 = computer()
c2 = computer()
so that the values would be different since it is a separate object from each other.
+ 1
Hi,
Python id() function returns an identity of an object. This is an integer which is guaranteed to be unique. This function takes an argument an object and returns a unique integer number which represents identity.
As arsensic told" Two objects with non-overlapping lifetimes may have the same id() value".
For more reference :
https://www.geeksforgeeks.org/id-function-python/