Implementing actual blocks in python

Hello,

I was thinking of an interesting feature for gnuradio: Suppose that the
gnuradio framework could also support blocks written in python. Not
hier-blocks, but actual data processing done in python. Meaning, one
would write a python class. The class would have an io signature, and a
function called work, where work would take a vector of floats/ints,
process the data, and return a vector of floats/ints (just like in the
c++). Yes, of course, this would be slower than c++. The idea favors
rapid testing, no recompiling; just run the flow graph again after
changing your python file.

Most likely, we would need some kind of “generic forwarding block”,
written in c++/swig, that would take a custom python class as an
argument, and swig would handle the passing of data into and out of the
work method of the python class.

I have no idea how this could be implemented with the current framework.
But if possible, this would be a tremendous thing to have.

Thoughts?
-Josh

On Tue, Nov 06, 2007 at 08:20:17PM -0500, Josh B. wrote:

changing your python file.
-Josh
Josh,

It could be implemented using SWIG directors.
They allow a C++ class w/ virtual functions to have virtual methods
defined in python subclasses.

Take a look at “directors” in the swig documentation.

Eric