I'm making a module to simulate a neural network, speed is an issue so I've written it in c, basically you build the network in python, and then run call a simulate method that is pure c.
One thing I want to add is the ability to inject current into the network as it runs, for this I thought I would have the user define a method that takes no arguments and returns a double and the network could use this as a callback function, but then I figured this would slow down the network by calling a method written in python, then I remembered ctypes.
So I wanted to ask, is PyObject_CallObject(my_callback, NULL) any slower then calling a c function if my_callback is written in c?