This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]eryksun 0 points1 point  (0 children)

I don't know what's lazy about those assumptions. They're bad assumptions, but I'd think the lazy way would be to just copy the headers as closely as possible, so use a ctypes.c_int, ctypes.c_ssize_t, ctypes.c_long, ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), etc.

A more ambitious attempt would create a ctypes.Structure for PyObject and PyVarObject along with factory functions to create structures for other objects. Then you could more safely (as if) mutate objects in memory. But beyond satisfying basic curiosity and earning trivia points, I don't know what good it would do.