blob: 0c851a75efbe1dba04fefda992eff1338190c2c7 [file] [log] [blame]
Georg Brandlf6842722008-01-19 22:08:21 +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
Sandro Tosi98ed08f2012-01-14 16:42:02 +010010than explicitly calling :c:func:`PyGen_New`.
Georg Brandlf6842722008-01-19 22:08:21 +000011
12
Sandro Tosi98ed08f2012-01-14 16:42:02 +010013.. c:type:: PyGenObject
Georg Brandlf6842722008-01-19 22:08:21 +000014
15 The C structure used for generator objects.
16
17
Sandro Tosi98ed08f2012-01-14 16:42:02 +010018.. c:var:: PyTypeObject PyGen_Type
Georg Brandlf6842722008-01-19 22:08:21 +000019
Martin Panter4ed35fc2015-10-10 10:52:35 +000020 The type object corresponding to generator objects.
Georg Brandlf6842722008-01-19 22:08:21 +000021
22
Sandro Tosi98ed08f2012-01-14 16:42:02 +010023.. c:function:: int PyGen_Check(ob)
Georg Brandlf6842722008-01-19 22:08:21 +000024
25 Return true if *ob* is a generator object; *ob* must not be *NULL*.
26
27
Sandro Tosi98ed08f2012-01-14 16:42:02 +010028.. c:function:: int PyGen_CheckExact(ob)
Georg Brandlf6842722008-01-19 22:08:21 +000029
30 Return true if *ob*'s type is *PyGen_Type* is a generator object; *ob* must not
31 be *NULL*.
32
33
Sandro Tosi98ed08f2012-01-14 16:42:02 +010034.. c:function:: PyObject* PyGen_New(PyFrameObject *frame)
Georg Brandlf6842722008-01-19 22:08:21 +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*.