See this code:
>>> import ctypes
>>> x=12345
>>> y=x
>>> ctypes.c_long.from_address(id(x)).value
2
>>> a=2
>>> b=a
>>> ctypes.c_long.from_address(id(a)).value
116
>>>
for object x it returned expected output but for "a" it's returning an unexpected result
I think this happens because you are reading a Python int object using the C long format. You are asking Python to read starting from
id(a)which is an address holding an object of int in Python. Starting from this address you are asking Python to read data as C long which is binary bits in two's complement.