blob: 33cd27a5aa6c44bf99a0630745000043d98da9c7 [file] [log] [blame]
Georg Brandl54a3faa2008-01-20 09:30:57 +00001.. highlightlang:: 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
Georg Brandl60203b42010-10-06 10:11:56 +000010than explicitly calling :c:func:`PyGen_New`.
Georg Brandl54a3faa2008-01-20 09:30:57 +000011
12
Georg Brandl60203b42010-10-06 10:11:56 +000013.. c:type:: PyGenObject
Georg Brandl54a3faa2008-01-20 09:30:57 +000014
15 The C structure used for generator objects.
16
17
Georg Brandl60203b42010-10-06 10:11:56 +000018.. c:var:: PyTypeObject PyGen_Type
Georg Brandl54a3faa2008-01-20 09:30:57 +000019
20 The type object corresponding to generator objects
21
22
Georg Brandl60203b42010-10-06 10:11:56 +000023.. c:function:: int PyGen_Check(ob)
Georg Brandl54a3faa2008-01-20 09:30:57 +000024
25 Return true if *ob* is a generator object; *ob* must not be *NULL*.
26
27
Georg Brandl60203b42010-10-06 10:11:56 +000028.. c:function:: int PyGen_CheckExact(ob)
Georg Brandl54a3faa2008-01-20 09:30:57 +000029
30 Return true if *ob*'s type is *PyGen_Type* is a generator object; *ob* must not
31 be *NULL*.
32
33
Georg Brandl60203b42010-10-06 10:11:56 +000034.. c:function:: PyObject* PyGen_New(PyFrameObject *frame)
Georg Brandl54a3faa2008-01-20 09:30:57 +000035
36 Create and return a new generator object based on the *frame* object. A
37 reference to *frame* is stolen by this function. The parameter must not be
38 *NULL*.