Skip to content

Instantly share code, notes, and snippets.



Created Feb 3, 2016
What would you like to do?
import cffi
ffi = cffi.FFI()
ffi.cdef('int PyDict_DelItemString(void *, const char *key);')
lib = ffi.dlopen('')
d = {'foo': 'bar'}
print('before', d)
d_p = ffi.cast('void*', id(d))
lib.PyDict_DelItemString(d_p,'char[]', b'foo'))
print('after', d)
assert 'foo' not in d
nathan@xxxxxx ~ $ python
before {'foo': 'bar'}
after {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment