제너레이터 객체

제너레이터 객체는 파이썬이 제너레이터 이터레이터를 구현하기 위해 사용하는 객체입니다. 일반적으로 PyGen_New() 또는 PyGen_NewWithQualName()를 명시적으로 호출하는 것이 아니라, 값을 일드(yield)하는 함수를 이터레이트하여 만들어집니다.

type PyGenObject

제너레이터 객체에 사용되는 C 구조체.

PyTypeObject PyGen_Type

제너레이터 객체에 해당하는 형 객체

int PyGen_Check(PyObject *ob)

ob가 제너레이터 객체면 참을 돌려줍니다; obNULL이 아니어야 합니다. 이 함수는 항상 성공합니다.

int PyGen_CheckExact(PyObject *ob)

ob의 형이 PyGen_Type이면 참을 돌려줍니다; obNULL이 아니어야 합니다. 이 함수는 항상 성공합니다.

PyObject *PyGen_New(PyFrameObject *frame)
반환값: 새 참조.

frame 객체에 기반한 새 제너레이터 객체를 만들어 반환합니다. 이 함수는 frame에 대한 참조를 훔칩니다. 인자는 NULL이 아니어야 합니다.

Deprecated since version 3.16, will be removed in version 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)
반환값: 새 참조.

frame 객체에 기반한 새 제너레이터 객체를 만들어 반환하는데, __name____qualname__namequalname로 설정합니다. 이 함수는 frame에 대한 참조를 훔칩니다. frame 인자는 NULL이 아니어야 합니다.

Deprecated since version 3.16, will be removed in version 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)

Return a new strong reference to the code object wrapped by gen. This function always succeeds.

Asynchronous Generator Objects

더 보기

PEP 525

PyTypeObject PyAsyncGen_Type

The type object corresponding to asynchronous generator objects. This is available as types.AsyncGeneratorType in the Python layer.

Added in version 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 and must not be NULL.

On success, this function returns a strong reference to the new asynchronous generator. On failure, this function returns NULL with an exception set.

Added in version 3.6.

Deprecated since version 3.16, will be removed in version 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.

int PyAsyncGen_CheckExact(PyObject *op)

Return true if op is an asynchronous generator object, false otherwise. This function always succeeds.

Added in version 3.6.

Deprecated API

PyAsyncGenASend_CheckExact(op)

This is an API that was included in Python’s C API by mistake.

It is solely here for completeness; do not use this API.

Soft deprecated since version 3.14.