Last active
January 22, 2018 01:26
-
-
Save sakurai-youhei/662dfc5d72b7a57f7fa828270a712a4d to your computer and use it in GitHub Desktop.
memoryview-like Python object view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import c_ubyte | |
from ctypes import cast | |
from ctypes import POINTER | |
from sys import getsizeof | |
def objview(obj): | |
return cast(id(obj), POINTER(c_ubyte * getsizeof(obj))).contents | |
''' | |
def balus(): | |
"""Word to let your interpreter crash""" | |
objview(1)[-4:] = 0, 0, 0, 0 | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment