Is there any way to build a C or C++ extension module that could be imported by
a Python ParaView plugin? Alternatively, is there any way to use Cython in a
Background: I’m building a Python reader plugin for a binary file format that
stores unstructured cell connectivity in a way that is slow to parse in Python.
I essentially have to do:
for i in range(numCells): header = np.fromfile(fin, np.int32, 1) cellType = header >> 18 if cellType == MY_FORMAT_TET: nodes = np.fromfile(fin, np.int32, 4) elif cellType == MY_FORMAT_HEX: nodes = np.fromfile(fin, np.int32, 8) ...
That loop is quite slow in Python for more than a million or so cells. In
standalone tools, I’ve been able to parse these files in Python quickly if I
can use a C extension module to handle the volume connectivity portion of the
I’d like to avoid building the entirety of this plugin in C++. I can’t expect
my users to compile the superbuild and then compile a plugin. A Python plugin
is a much lower bar.