[capi-sig] Problem with reference
Gustavo Carneiro
gjcarneiro at gmail.com
Tue Mar 3 16:01:52 CET 2009
2009/3/3 Stefan Behnel <python_capi at behnel.de>
> Gustavo Carneiro wrote:
> > And Cython *is* a wrapper generator.
>
> Well, no, but PyBindGen is, now that you mention it. It looks a bit like a
> FFI (like ctypes), but it generates the corresponding wrapper code, if I'm
> not mistaken. Using it for anything but wrapping C/C++ code to make it
> callable in Python would be futile.
>
> Cython is (literally) not a wrapper generator as it will not generate a
> wrapper for you. You have to write it yourself. Cython is a programming
> language to write extension modules for CPython, as generic as that. It
> focuses on Python-like simplicity, C-like speed and easy interfacing with
> both CPython and C (while better C++ and Fortran support is still being
> fledged out). It is being used to write wrappers, but it is also being
> used to write high-performance computational code, with or without
> interfacing to external C libraries. In the second line, it's also heading
> to become a fully-compliant Python compiler (a 1.0 goal), but that doesn't
> belong here (just like the automatic-compile-on-import support for Python
> files *wink*).
OK, but surely we can say that Cython is a code generator, or compiler. So
it's more generic than a wrapper generator. But it can fulfill the role of
wrapper generator, even if it means writing more code than other tools for
describing the same API. For me, wrapper is any C/C++ code that bindings
Python to a C/C++ library. If Cython can generate that code, then Cython
can also be considered a wrapper generator, or at least the engine for a
wrapper generator. It is more or less at the same level as Boost.Python.
You also have to write the wrapper code using Boost.Python yourself...
>
>
>
> > I clearly remember seeing (ugly) C
> > code generated by Cython, before I decided to write PyBindGen.
>
> Let's not start a discussion about taste here. Readable, commented, easy
> to debug C code is an obvious goal of the Cython project, simply because
> its developers are those who debug it most of the time. That said, we
> generally tell our users to look at the highlighted HTML page that Cython
> generates of their source code, so that they can focus more easily on
> those parts of the generated C code that are worth optimising. Having to
> read the entire C code file just to see where things go wrong is not a
> good idea.
OK. I won't comment except to mention that I am glad the Cython project
wants to generate readable code.
Regards,
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
More information about the capi-sig
mailing list