Is there a way to compile on the fly new classes inheriting a VTK class in python?

I would need to be able to let users define new classes inheriting an abstract vtk class inheriting vtkDataObject with a few simple methods / static attributes to redefine. Is it possible in python to do this kind of stuff?

The typical application for such a feature would be for example, given a set of known parameters, to be able to compute what ever quantity out of them, or to allow to gather those parameters in a different way. For instance, one could want to compute the arithmetic mean of some data, but maybe it would want to compute the harmonic mean instead, or the entropy. It could be possible to implement all of those in different inherited classes, but who knows which other weird computation could someone need.

Of course a user who programs can create its own inherited class and compile it / feed it where ever needed, but I would need that to be able to be done in ParaView, at run-time.

Is there any way that could be doable?

In 3D Slicer, for cases when there is an interface defined in C++ and we want to implement behavior in Python, we create a subclass in C++ that can call methods of a Python object. See for example this C++ subclass and a Python implementation class. You use this by instantiating the C++ object and call vtkMRMLScriptedDisplayableManager::SetPythonSource(const std::string& pythonSource).

It sounds like you need to implement an adapter pattern in Python to wrap your vtkDataObject instances