Skip to content

Instantly share code, notes, and snippets.

@DavidJFelix
Created July 26, 2014 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidJFelix/d5a100f0a38400f30995 to your computer and use it in GitHub Desktop.
Save DavidJFelix/d5a100f0a38400f30995 to your computer and use it in GitHub Desktop.
Modify python behavior
from ctypes import c_int8
from struct import calcsize
# Make 4 = 5
c_int8.from_address(id(4) + calcsize('PP')).value = 5
# A little more readable
address = id(4)
offset = calcsize('PP')
pyint_data = c_int8.from_address(address + offset)
pyint_data.value = 5
from ctypes import c_int8
from struct import calcsize
# Make 4 = 5
c_int8.from_address(id(4) + calcsize('PPP')).value = 5
# A little more readable
address = id(4)
offset = calcsize('PP')
pyint_data = c_int8.from_address(address + offset)
pyint_data.value = 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment