+ 1
Can u explain about this code? , i did'nt understand about this code
x=11 print (id(x)) x=x+1 print (id(x))
4 Answers
+ 2
id(obj)
returns the unique identity for object.
cpython uses the memory address of the object
when you initialized x = 11
Python creates object inside memory with value 11 and x refers to it
x = x + 1
here python creates another object 11 + 1 = 12 now x refers to another object and previous object get cleared by garbage collector.
+ 2
garbage collector is a program which free up the memory by removing dead objects
whenever we create object python keeps count on it
when count is 0 garbage collector get invoked and removes the object when their is no reference to that object .
0
Can you explain what is garbage collector?
0
Yeah! Thanks its help me a lot.........đ