I would like to make use of a couple of C++ libraries from within Python to provide a Python API for scripting a C++ application. So I am wondering if there are any performance implications of passing a Python tuple in place of a C++ struct to a C++ function? Also, are the two data structures the same? If the two are the same, how can I prevent a tuple with incompatible member types from being passed? Would that impact the performance? If that impacts performance, what are the best practices for dealing with such situations in Python. Please note that I am clearly not the author of the libraries.
There's almost no relationship between a Python tuple and
a struct in C++.  The elements of a tuple are neither named
nor typed, and must be accessed (in C++) through functions in
the Python C API (PyTuple_GetItem, etc.).  Internally
(although you don't have access to it directly), a tuple is an
array of pointers to objects.  Even for types like int and
float. 
Because of the function calls and the added levels of
indirection, using a Python tuple will be slower than using
a struct.  The "best practice" is to write a wrapper function,
which extracts the information from the tuple, doing the dynamic
type checking, etc., and use it to initialize the struct which
you then send on the the C++ function.  There's really no other
way.
Are there any performance implications of passing a Python tuple in place of a C++ struct function argument?