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

0
7
Asked By CuriousCoder42 On

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!

1 Answer

Answered By TechGuru99 On

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?

Questioner1 -

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?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.