Confused About C APIs for PyPy and CPython? Let's Clarify!

October 19, 2025 1 answer
Asked by west exit 63
Hey everyone! I've got a question about the differences between PyPy and CPython, specifically regarding the C API. CPython is written in C and has a dedicated C API that lets you manually call C functions without needing extra libraries like ctypes or cffi. But I'm curiousโ€”since PyPy eventually compiles down to C, why doesn't it have a similar C API? Can you actually interface with C manually in PyPy? I know there are other methods for doing this, but I'm really trying to fill in the blanks about creating wrappers and binders between these languages. Appreciate any insights!

Answers

pre-dawn baker
Your question is a bit unclear, but just to clarify, both CPython and PyPy can use C Foreign Function Interfaces (FFI), so the fact they are implemented in C isn't really relevant here. If you're looking for a more manual approach versus other methods, could you specify what you're thinking about?

ready-set-go!: I get that CFFI works for both, but CPython has that actual C API. I'm curious why PyPy lacks one even though it converts to C code later. Also, if I wrap C in an RPython program, I know the JIT won't optimize it, but does anything else optimize it after using ctypes or CFFI?

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions