1.. highlight:: c
2
3.. _gen-objects:
4
5Generator Objects
6-----------------
7
8Generator objects are what Python uses to implement generator iterators. They
9are normally created by iterating over a function that yields values, rather
10than explicitly calling :c:func:`PyGen_New` or :c:func:`PyGen_NewWithQualName`.
11
12
13.. c:type:: PyGenObject
14
15   The C structure used for generator objects.
16
17
18.. c:var:: PyTypeObject PyGen_Type
19
20   The type object corresponding to generator objects.
21
22
23.. c:function:: int PyGen_Check(PyObject *ob)
24
25   Return true if *ob* is a generator object; *ob* must not be ``NULL``.
26
27
28.. c:function:: int PyGen_CheckExact(PyObject *ob)
29
30   Return true if *ob*'s type is :c:type:`PyGen_Type`; *ob* must not be ``NULL``.
31
32
33.. c:function:: PyObject* PyGen_New(PyFrameObject *frame)
34
35   Create and return a new generator object based on the *frame* object.
36   A reference to *frame* is stolen by this function. The argument must not be
37   ``NULL``.
38
39.. c:function:: PyObject* PyGen_NewWithQualName(PyFrameObject *frame, PyObject *name, PyObject *qualname)
40
41   Create and return a new generator object based on the *frame* object,
42   with ``__name__`` and ``__qualname__`` set to *name* and *qualname*.
43   A reference to *frame* is stolen by this function.  The *frame* argument
44   must not be ``NULL``.
45