產生器 (Generator) 物件¶
產生器物件是 Python 用來實現產生器疊代器 (generator iterator) 的物件。它們通常透過疊代會產生值的函式來建立,而不是顯式呼叫 PyGen_New() 或 PyGen_NewWithQualName()。
-
type PyGenObject¶
用於產生器物件的 C 結構。
-
PyTypeObject PyGen_Type¶
與產生器物件對應的型別物件。
-
int PyGen_CheckExact(PyObject *ob)¶
如果 ob 的型別是
PyGen_Type則回傳真值;ob 必須不為NULL。此函式總是會成功執行。
-
PyObject *PyGen_New(PyFrameObject *frame)¶
- 回傳值:新的參照。
Create and return a new generator object based on the frame object. A reference to frame is "stolen" by this function (even on error). The argument must not be
NULL.自從版本 3.16 後不推薦使用,將會自版本 3.18 中移除。: This function has not been used since 3.10. It is also impossible to construct a proper frame object to call this function.
-
PyObject *PyGen_NewWithQualName(PyFrameObject *frame, PyObject *name, PyObject *qualname)¶
- 回傳值:新的參照。
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 (even on error). The frame argument must not beNULL.自從版本 3.16 後不推薦使用,將會自版本 3.18 中移除。: This function has not been used since 3.10. It is also impossible to construct a proper frame object to call this function.
-
PyCodeObject *PyGen_GetCode(PyGenObject *gen)¶
回傳一個對 gen 所包裝的程式碼物件的新強參照。此函式總是會成功執行。
非同步產生器 (Asynchronous Generator) 物件¶
也參考
-
PyTypeObject PyAsyncGen_Type¶
與非同步產生器物件對應的型別物件。在 Python 層中可以
types.AsyncGeneratorType使用。在 3.6 版被加入.
-
PyObject *PyAsyncGen_New(PyFrameObject *frame, PyObject *name, PyObject *qualname)¶
Create a new asynchronous generator wrapping frame, with
__name__and__qualname__set to name and qualname. frame is "stolen" by this function (even on error) and must not beNULL.成功時此函式回傳對新的非同步產生器的強參照。失敗時此函式回傳
NULL並設定一個例外。在 3.6 版被加入.
自從版本 3.16 後不推薦使用,將會自版本 3.18 中移除。: This function has not been used since 3.10. It is also impossible to construct a proper frame object to call this function.
已棄用的 API¶
-
PyAsyncGenASend_CheckExact(op)¶
This is an API that was included in Python's C API by mistake.
它僅僅是為了完整性而存在;請勿使用此 API。
Soft deprecated since version 3.14.