import sys
a = 10
b = a
print sys.getrefcount(a)
b=1
print sys.getrefcount(b)
output:
22
614
Is there any problem with my
You can see the effects of Python's optimizations (see @Nether's answer) if you change the values to non-trivial ones. For instance, if your code is changed to:
from __future__ import print_function
import sys
a = 1012345
b = a
print(sys.getrefcount(a))
b=12345678
print(sys.getrefcount(b))
The output is:
5
4