CPyCPy
import cffi | |
ffi = cffi.FFI() | |
ffi.cdef('int PyDict_DelItemString(void *, const char *key);') | |
lib = ffi.dlopen('libpython3.so') | |
d = {'foo': 'bar'} | |
print('before', d) | |
d_p = ffi.cast('void*', id(d)) | |
lib.PyDict_DelItemString(d_p, ffi.new('char[]', b'foo')) | |
print('after', d) | |
assert 'foo' not in d |
nathan@xxxxxx ~ $ python cpycpy.py | |
before {'foo': 'bar'} | |
after {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment