[Python-Dev] (ctypes example) libffi embedded in CPython
Maciej Fijalkowski
fijall at gmail.com
Wed Mar 11 22:13:29 CET 2015
More information about the Python-Dev mailing list
Wed Mar 11 22:13:29 CET 2015
- Previous message (by thread): [Python-Dev] (ctypes example) libffi embedded in CPython
- Next message (by thread): [Python-Dev] (ctypes example) libffi embedded in CPython
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Mar 11, 2015 at 8:17 PM, Antoine Pitrou <solipsis at pitrou.net> wrote: > On Wed, 11 Mar 2015 19:05:57 +0100 > Antoine Pitrou <solipsis at pitrou.net> wrote: >> > > >> > > But they are not ctypes. For example, cffi wouldn't be obvious to use >> > > for interfacing with non-C code, since it requires you to write C-like >> > > declarations. >> > >> > You mean like Fortran? Or what precisely? >> >> Any toolchain that can generate native code. It can be Fortran, but it >> can also be code generated at runtime without there being any external >> declaration. Having to generate "C declarations" for such code would be >> a distraction. > > For instance, you can look at the compiler example that Eli wrote using > llvmlite. It implements a JIT compiler for a toy language. The > JIT-compiled function is then declared and called using a simple ctypes > declaration: > > https://github.com/eliben/pykaleidoscope/blob/master/chapter7.py#L937 > > Regards > > Antoine. It might be a matter of taste, but I don't find declaring C functions any more awkward than using strange interface that ctypes comes with. the equivalent in cffi would be ffi.cast("double (*)()", x)
- Previous message (by thread): [Python-Dev] (ctypes example) libffi embedded in CPython
- Next message (by thread): [Python-Dev] (ctypes example) libffi embedded in CPython
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list