You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, both C2PY_IGNORE/C2PY_WRAP and match_names/reject_names don't seem to allow users to customize the wrapping of individual members within a class. It would be very helpful to have the ability to selectively wrap specific members of a C++ class when exposing it to Python.
For example, in the following MF class, bound to my_module:
// mf.cpp
#include <c2py/c2py.hpp>
struct MF {
MF(int _nkpts, int _nsin):
nkpts(_nkpts), nspin(_nspin) {}
int nkpts;
C2PY_IGNORE int nspin;
};
# CMakeLists.txt
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(mpi_context VERSION 3.2.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
# Find Python, c2py and clair
find_package(Python COMPONENTS Interpreter Development NumPy)
find_package(c2py REQUIRED)
find_package(clair REQUIRED)
Python_add_library(my_module MODULE mf.cpp)
# Link to low level c2py and add the -fplugin option using a cmake target.
target_link_libraries(my_module PRIVATE c2py::c2py clair::c2py_plugin)
I would like to expose only nkpts in Python, while keeping nspin hidden:
There are many cases where binding a class but selectively exposing only certain members to Python is desired. This is particularly useful when a member, such as nspin, is not a standard type, allowing users to avoid the need to write a customized py_converter for it.
The text was updated successfully, but these errors were encountered:
Summary
Currently, both
C2PY_IGNORE/C2PY_WRAP
andmatch_names/reject_names
don't seem to allow users to customize the wrapping of individual members within a class. It would be very helpful to have the ability to selectively wrap specific members of a C++ class when exposing it to Python.For example, in the following
MF
class, bound tomy_module
:I would like to expose only
nkpts
in Python, while keepingnspin
hidden:Motivation
There are many cases where binding a class but selectively exposing only certain members to Python is desired. This is particularly useful when a member, such as
nspin
, is not a standard type, allowing users to avoid the need to write a customized py_converter for it.The text was updated successfully, but these errors were encountered: