A developer identified that 29% of CPU time in the standard async_generators benchmark for CPython was consumed by unnecessary exception handling. The runtime was repeatedly creating and destroying StopIteration exception objects during internal data transfers between C functions.

The issue stemmed from the PyAsyncGenASend_Send function, which used StopIteration exceptions as a temporary interface to pass pointers between internal C functions. This process involved redundant memory allocation and deallocation for every element in nested generator pipelines.

The proposed fix introduces a new C helper, async_gen_unwrap_send, which returns status via the PySendResult enum instead of raising exceptions. This change allows the runtime to pass values directly through pointers, bypassing the thread-state error mechanism.

Additionally, the developer optimized the async_gen_asend_dealloc function by restricting the call to PyObject_CallFinalizerFromDealloc. This prevents unnecessary finalizer checks for coroutines that are already in the iteration or closed state.

Following these modifications to genobject.c, the async_generators benchmark showed a performance improvement of 1.33x to 1.53x. The patch passed the full Python test suite of 491 tests without errors, with other benchmarks remaining within the margin of error.