Also should it be specific to generators/coroutines and accept PyGenObject* or should it try to handle multiple cases and expose the result for them in uniform way, i.e.
```
if (PyGen_CheckExact(gen) || PyCoro_CheckExact(gen)) {
// use coroutine/generator specific code that avoids raising exceptions
*result = ...
return PYGEN_RETURN;
}
PyObject *ret;
if (arg == Py_None) {
ret = Py_TYPE(gen)->tp_iternext(gen);
}
else {
ret = _PyObject_CallMethodIdOneArg(coro, &PyId_send, arg);
}
if (ret != NULL) {
*result = ret;
return PYGEN_YIELD;
}
if (_PyGen_FetchStopIterationValue(result) == 0) {
return PYGEN_RETURN;
}
return PYGEN_ERROR;
``` |