+ 1
object oriented programming #python #output
a = 42 # Create object <42> b = a # Increase ref. count of <42> c = [a] # Increase ref. count of <42> del a # Decrease ref. count of <42> b = 100 # Decrease ref. count of <42> HOW...?? c[0] = -1 # Decrease ref. count of <42> HOW...??? HAS THE OBJECT'S REFERENCE COUNT REDUCED TO ZERO...??
1 Answer
+ 1
int values are special internal objects which always exists and their refcount cannot be 0. int 42 object exists as soon as you start python, it is not created at first line if tout script. Each time a variable references int 42 its refcount increases, and each time the value takes another int value, 42 refcount decreases...