Search code examples
pythoncheat-engine

Why is id different through id() and through the cheat engine?


When I run the code and then check the variable id using the cheat engine, they are different, why?

Here's what i have:

import time

x = 500

while True:
    time.sleep(1)
    print(f'ID: 0x{format(id(x), "X")}\nValue: {x}')

code result and cheat engine


Solution

  • The "cheat engine" is showing you the location of the data itself. The id is the address of the integer object. Each object (even integers) has structure overhead.