Last active
January 3, 2016 12:59
-
-
Save aebrahim/8466660 to your computer and use it in GitHub Desktop.
This file contains 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
# copied from http://code.activestate.com/recipes/576540/history/2/ | |
from ctypes import pythonapi, py_object | |
from _ctypes import PyObj_FromPtr | |
PyDictProxy_New = pythonapi.PyDictProxy_New | |
PyDictProxy_New.argtypes = (py_object,) | |
PyDictProxy_New.rettype = py_object | |
def make_dictproxy(obj): | |
assert isinstance(obj,dict) | |
return PyObj_FromPtr(PyDictProxy_New(obj)) | |
a = {"swallow": "unladen"} | |
b = make_dictproxy(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment