Skip to content

Instantly share code, notes, and snippets.

@aebrahim
Last active January 3, 2016 12:59
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 aebrahim/8466660 to your computer and use it in GitHub Desktop.
Save aebrahim/8466660 to your computer and use it in GitHub Desktop.
# 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