# 生成器对象

生成器对象是Python用来实现生成器迭代器的对象。它们通常通过迭代产生值的函数来创建，而不是显式调用 `PyGen_New()` 或 `PyGen_NewWithQualName()`。

`PyGenObject`

  用于生成器对象的C结构体。

PyTypeObject `PyGen_Type`

  与生成器对象对应的类型对​​象。

int `PyGen_Check`(PyObject *ob)

  Return true if ob is a generator object; ob must not be NULL.

int `PyGen_CheckExact`(PyObject *ob)

  Return true if ob’s type is PyGen_Type; ob must not be NULL.

PyObject* `PyGen_New`(PyFrameObject *frame)
  Return value: New reference.

  Create and return a new generator object based on the frame object. A reference to frame 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 the frame object, with `__name__` and `__qualname__` set to name and qualname. A reference to frame is stolen by this function. The frame argument must not be NULL.