• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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``.  This
26   function always succeeds.
27
28
29.. c:function:: int PyGen_CheckExact(PyObject *ob)
30
31   Return true if *ob*'s type is :c:type:`PyGen_Type`; *ob* must not be
32   ``NULL``.  This function always succeeds.
33
34
35.. c:function:: PyObject* PyGen_New(PyFrameObject *frame)
36
37   Create and return a new generator object based on the *frame* object.
38   A reference to *frame* is stolen by this function. The argument must not be
39   ``NULL``.
40
41.. c:function:: PyObject* PyGen_NewWithQualName(PyFrameObject *frame, PyObject *name, PyObject *qualname)
42
43   Create and return a new generator object based on the *frame* object,
44   with ``__name__`` and ``__qualname__`` set to *name* and *qualname*.
45   A reference to *frame* is stolen by this function.  The *frame* argument
46   must not be ``NULL``.
47