NextGen TotalView for HPC User Guide : PART II Debugging Tools and Tasks : Chapter 7 Debugging Python : Supported Python Extension Technologies for Stack Transformations
Supported Python Extension Technologies for Stack Transformations
Natively, Python provides the foreign function library ctypes, which provides an infrastructure for calling functions in shared libraries and the exchange of C compatible data types between the language barriers.
The library ctypes is not the only solution for calling C; numerous other "glue" technologies exist, implementing an array of approaches to facilitate calling between and exchanging data between Python and C and C++.
Common Python Extension Technologies that Support Stack Transformations
Table 5: Python Extension Technologies for Stack Transformations
Python C/C++ "Glue" Technology
Description
ctypes
A foreign function library for Python.
https://docs.python.org/3/library/ctypes.html
Cython
A superset of the Python language that additionally supports calling C functions and declaring C types on variables and class attributes.
http://cython.org/
SWIG
A software development tool that connects programs written in C and C++ with a variety of high-level programming languages including Python.
http://www.swig.org/Doc3.0/Python.html
CFFI
Foreign Function Interface for Python calling C code.
http://cffi.readthedocs.io/en/latest/index.html
PyQt/PySide and SIP
SIP is a tool that makes it easy to create Python bindings for C and C++ libraries.
https://www.riverbankcomputing.com/software/sip/intro
http://pyqt.sourceforge.net/Docs/sip4/introduction.html
Boost.Python
A C++ library which enables seamless interoperability between C++ and the Python programming language.
http://www.boost.org/doc/libs/1_63_0/libs/python/doc/html/index.html
Python Extension Filters Supported by TotalView
has built-in logic to identify and transform the low-level calls in the Python interpreter functions and extract the Python call and variable information. Filtering out the Python extension "glue" code requires further rule definitions tailored to the specific technology. The following table shows the current Python extension filters supported by TotalView.
Table 6: Python Extension Filters Supported by TotalView
Python C/C++ "Glue" Technology
Description
ctypes
A foreign function library for Python.
https://docs.python.org/3/library/ctypes.html
SWIG
A software development tool that connects programs written in C and C++ with a variety of high-level programming languages including Python.
http://www.swig.org/Doc3.0/Python.html
Support for more Python extensions will be added over time but you can also define your own transformation and filter rules as well. Check out the dstacktransform documentation for details on creating your own stack transformations.