Cppyy – Automatic Python-C++ bindings

by d3kon 5/7/2019, 11:33 AMwith 22 comments

by kazinatoron 5/7/2019, 6:17 PM

How does this know the difference between:

  const char *cls::func(void)
  {
     return "abc"; // static: caller must not free
  }
and

  const char *cls::func(void)
  {
     return strdup("abc"); // caller must free
  }
Edit: I see: designed for large scale programs in high performance computing that use modern C++.

Modern C++ meaning, no pointers anywhere.

by malkiaon 5/7/2019, 4:00 PM

There is also the less known https://github.com/google/clif (but not automatic)

by backslash_16on 5/7/2019, 6:03 PM

From the comments below, it sounds like interfacing my C++ code with python using Cppyy would sacrifice performance.

Even so this will be awesome for unit testing. I really like the testing interface pytest provides, along with its parametrized tests.

Anyone else using python to test the logic their C/C++ code? I can't think of how I would test the memory allocation and freeing portion. Anyone think it's a bad idea?

by gshulegaardon 5/7/2019, 3:59 PM

This is super interesting but if I am looking to bring C++ into my Python code base it would be because performance is important enough to do so. With that in mind I am not sure how this stacks up against compiled half steps like Cython or foreign function interfaces likes ctypes or CFFI instead.

by jrussinoon 5/7/2019, 5:27 PM

I need to create Python bindings for a C++ library and after a brief survey of the available options was planning on using SWIG (http://www.swig.org/tutorial.html). How does this compare?

by hatredon 5/7/2019, 4:05 PM

Does anyone know of any well known tools that generate bindings in other languages e.g., Python from C++ code?

IIUC, this tool does the opposite i.e., generate C++/other language bindings from Python

by corysamaon 5/7/2019, 5:20 PM

> PyPy 5.7 and 5.8 have a built-in module cppyy.

Nice.

by adenneron 5/7/2019, 4:31 PM

How does this compare to pybind11?

by ttulon 5/8/2019, 12:01 AM

Google PyInline