Skip to content

Comment on Want to call C from Python? Use Dparent

Comments

ctypes does not parse C headers and doesn't know about enums or function parameter types — only that they have a symbol in the .dynsym section of a .so.

Maybe you're thinking of cffi? Cffi does basically what this blog post covers, except without D. It requires a C compiler at some stage in the process, but you can pregenerate during 'build' phase and ship a header snapshot to avoid requiring the C compiler at runtime.

I didn’t say ctypes takes the same approach — I even mentioned ctypes’ shortcomings. I only said ctypes makes what this does possible already.

No, ctypes does not. It can't handle macros, and it requires users to define the structures in Python themselves. It's miles away from what's in the blog post.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.