I'm working on a python module implemented using the "C" API for Python 3.7. I'm trying to speed up a PySequence_Fast() loop that calls a function using PyObject_CallMethod(). Since the objects are all the same python class, I was hoping to avoid the overhead of resolving the function name each time. Is that possible?
Here's the (reduced) code fragment I'm trying to improve:
PyObject *seq = PySequence_Fast(object_list,"not a sequence");
int len = PySequence_Size(object_list);
for ( int n = 0 ; n < len ; n++ )
{
PyObject *obj = PyList_GET_ITEM(seq,n);
PyObject_CallMethod(obj,"my_function",NULL);
}
Thanks in advance.