0

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

Mityailr
  • 3
  • 1
  • 1
    `id()` gives you the address of the Python object - which will include its reference count, link to the type that defines the object, and possibly other fields prior to the actual object data. – jasonharper Apr 27 '22 at 21:22

1 Answers1

3

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.

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30