Hello,
Python 3.10 comes with the built-in *anext()* but I think we may be missing
some other equivalent built-in functions like *list* and *enumerate*.
I didn't discuss the idea of creating a PEP for this but I would like to
get some help with the implementation.
The equivalent Python code would be
*async def aenumerate(sequence, start=0): n = start async for elem in
sequence: yield n, elem n += 1*
The code for enumerate if here
https://github.com/python/cpython/blob/2f3a87856c7033227577b9ed0c77ed75311430b7/Objects/enumobject.c#L42
The *next* function creates a tuple and return with (n, elem)
*result = PyTuple_New(2);PyTuple_SET_ITEM(result, 0,
next_index);PyTuple_SET_ITEM(result, 1, next_item);return result;*
For the async implementation I would have to instead return an
*async_generator_asend* object
and that would resolve to the tuple. Calling *tp_as_async->am_anext* and
getting the value doesn't seem like the solution because I should not get
the result at this stage yet.
I would like to have a hint on how to implement this =D
Python 3.10 comes with the built-in *anext()* but I think we may be missing
some other equivalent built-in functions like *list* and *enumerate*.
I didn't discuss the idea of creating a PEP for this but I would like to
get some help with the implementation.
The equivalent Python code would be
*async def aenumerate(sequence, start=0): n = start async for elem in
sequence: yield n, elem n += 1*
The code for enumerate if here
https://github.com/python/cpython/blob/2f3a87856c7033227577b9ed0c77ed75311430b7/Objects/enumobject.c#L42
The *next* function creates a tuple and return with (n, elem)
*result = PyTuple_New(2);PyTuple_SET_ITEM(result, 0,
next_index);PyTuple_SET_ITEM(result, 1, next_item);return result;*
For the async implementation I would have to instead return an
*async_generator_asend* object
and that would resolve to the tuple. Calling *tp_as_async->am_anext* and
getting the value doesn't seem like the solution because I should not get
the result at this stage yet.
I would like to have a hint on how to implement this =D