[Numpy-discussion] NumPtr vs NumPy.i to access C
Sat May 17 20:43:36 CDT 2008
On Sat, May 17, 2008 at 8:13 PM, Nathan Bell <email@example.com> wrote:
> On Sat, May 17, 2008 at 7:48 PM, Robert Kern <firstname.lastname@example.org> wrote:
>> For the purposes to which SWIG was applied in that case, the findings
>> are accurate.
> IMO it's deliberately misleading. The following three layers are
> spurious and have no analog on the Cython stack:
> Python code to provide a clean interface
> Handcode C++ Integer class
> GMP's C++ Interface
If you want to end up with a class, that's more or less what you would
do in SWIG. Some bits in Python, because they're dealing with Python
types and exceptions and such. Some bits in C++ because you need to
touch C/C++ structures. Just wrapping the functions in SWIG and then
making the class in pure Python can sometimes work, but often you need
to make a C++ class sitting on top of your library.
Except for possibly the GMP C++ layer (perhaps the handwritten C++
class could just have used the GMP C API, I don't know), they're not
spurious. All of that functionality that was implemented in those
layers were implemented in the single Cython layer.
> A more honest comparison would list 3 layers for SWIG vs. 2 layers for Cython.
> I don't have a hard time believing that Cython is a better choice for
> fine-grained access to C/C++ code. However contrived scenarios like
> the above don't inspire my confidence either.
It was not contrived. It's production code. It was a real and
perfectly valid use case.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion