Generator Objects¶
Generator objects are what Python uses to implement generator iterators. Theyare normally created by iterating over a function that yields values, ratherthan explicitly callingPyGen_New() orPyGen_NewWithQualName().
- typePyGenObject¶
The C structure used for generator objects.
- PyTypeObjectPyGen_Type¶
The type object corresponding to generator objects.
- intPyGen_Check(PyObject*ob)¶
Return true ifob is a generator object;ob must not be
NULL. Thisfunction always succeeds.
- intPyGen_CheckExact(PyObject*ob)¶
Return true ifob’s type is
PyGen_Type;ob must not beNULL. This function always succeeds.
- PyObject*PyGen_New(PyFrameObject*frame)¶
- Return value: New reference.
Create and return a new generator object based on theframe object.A reference toframe is stolen by this function. The argument must not be
NULL.
- PyObject*PyGen_NewWithQualName(PyFrameObject*frame,PyObject*name,PyObject*qualname)¶
- Return value: New reference.
Create and return a new generator object based on theframe object,with
__name__and__qualname__set toname andqualname.A reference toframe is stolen by this function. Theframe argumentmust not beNULL.
- PyCodeObject*PyGen_GetCode(PyGenObject*gen)¶
Return a newstrong reference to the code object wrapped bygen.This function always succeeds.
Asynchronous Generator Objects¶
See also
- PyTypeObjectPyAsyncGen_Type¶
The type object corresponding to asynchronous generator objects. This isavailable as
types.AsyncGeneratorTypein the Python layer.Added in version 3.6.
- PyObject*PyAsyncGen_New(PyFrameObject*frame,PyObject*name,PyObject*qualname)¶
Create a new asynchronous generator wrappingframe, with
__name__and__qualname__set toname andqualname.frame is stolen by thisfunction and must not beNULL.On success, this function returns astrong reference to thenew asynchronous generator. On failure, this function returns
NULLwith an exception set.Added in version 3.6.