タプルオブジェクト (tuple object)
*********************************

PyTupleObject

   この "PyObject" のサブタイプは Python のタプルオブジェクトを表現し
   ます。

PyTypeObject PyTuple_Type

   この "PyTypeObject" のインスタンスは Python のタプル型を表現します;
   Python レイヤにおける "tuple" と同じオブジェクトです。

int PyTuple_Check(PyObject *p)

   *p* がタプルオブジェクトか、タプル型のサブタイプのインスタンスであ
   る場合に真を返します。

int PyTuple_CheckExact(PyObject *p)

   *p* がタプルオブジェクトで、かつタプル型のサブタイプのインスタンス
   でない場合に真を返します。

PyObject* PyTuple_New(Py_ssize_t len)
    *Return value: New reference.*

   サイズが *len* の新たなタプルオブジェクトを返します。失敗すると
   "NULL" を返します。

PyObject* PyTuple_Pack(Py_ssize_t n, ...)
    *Return value: New reference.*

   サイズが *n* の新たなタプルオブジェクトを返します。失敗すると
   "NULL" を返します。タプルの値は後続の *n* 個の Python オブジェクト
   を指す C 引数になります。"PyTuple_Pack(2, a, b)" は
   "Py_BuildValue("(OO)", a, b)" と同じです。

Py_ssize_t PyTuple_Size(PyObject *p)

   タプルオブジェクトへのポインタを引数にとり、そのタプルのサイズを返
   します。

Py_ssize_t PyTuple_GET_SIZE(PyObject *p)

   タプル *p* のサイズを返しますが、*p* は非 "NULL" でなくてはならず、
   タプルオブジェクトを指していなければなりません; この関数はエラーチ
   ェックを行いません。

PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos)
    *Return value: Borrowed reference.*

   Return the object at position *pos* in the tuple pointed to by *p*.
   If *pos* is out of bounds, return "NULL" and set an "IndexError"
   exception.

PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos)
    *Return value: Borrowed reference.*

   "PyTuple_GetItem()" に似ていますが、引数に対するエラーチェックを行
   いません。

PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high)
    *Return value: New reference.*

   Return the slice of the tuple pointed to by *p* between *low* and
   *high*, or "NULL" on failure.  This is the equivalent of the Python
   expression "p[low:high]".  Indexing from the end of the list is not
   supported.

int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)

   Insert a reference to object *o* at position *pos* of the tuple
   pointed to by *p*.  Return "0" on success.  If *pos* is out of
   bounds, return "-1" and set an "IndexError" exception.

   注釈:

     This function "steals" a reference to *o* and discards a
     reference to an item already in the tuple at the affected
     position.

void PyTuple_SET_ITEM(PyObject *p, Py_ssize_t pos, PyObject *o)

   "PyTuple_SetItem()" に似ていますが、エラーチェックを行わず、新たな
   タプルに値を入れるとき *以外には使ってはなりません* 。

   注釈:

     This macro "steals" a reference to *o*, and, unlike
     "PyTuple_SetItem()", does *not* discard a reference to any item
     that is being replaced; any reference in the tuple at position
     *pos* will be leaked.

int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize)

   タプルをリサイズする際に使えます。 *newsize* はタプルの新たな長さで
   す。タプルは変更不能なオブジェクト *ということになっている* ので、
   この関数はこのオブジェクトに対してただ一つしか参照がない時以外には
   使ってはなりません。タプルがコード中の他の部分ですでに参照されてい
   る場合には、この関数を *使ってはなりません* 。タプルは常に指定サイ
   ズの末尾まで伸縮します。成功した場合には "0" を返します。クライアン
   トコードは、 "*p" の値が呼び出し前と同じになると期待してはなりませ
   ん。 "*p" が置き換えられた場合、オリジナルの "*p" は破壊されます。
   失敗すると "-1" を返し、 "*p" を "NULL" に設定して、  "MemoryError"
   または "SystemError" を送出します。

int PyTuple_ClearFreeList()

   free list をクリアします。解放された要素数を返します。


Struct Sequence オブジェクト
****************************

struct sequence オブジェクトは "namedtuple()" オブジェクトと等価なC オ
ブジェクトです。 つまり、その要素に属性を通してアクセスすることができ
るシーケンスです。 struct sequence を生成するには、まず特定のstruct
sequence 型を生成しなければなりません。

PyTypeObject* PyStructSequence_NewType(PyStructSequence_Desc *desc)
    *Return value: New reference.*

   後述の *desc* 中のデータから新しい struct sequence 型を生成します。
   返される型のインスタンスは "PyStructSequence_New()" で生成できます
   。

void PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc)

   struct sequence 型である *type* を *desc* をもとにその場で初期化し
   ます。

int PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc)

   "PyStructSequence_InitType" と同じですが、成功した場合には "0" を、
   失敗した場合には "-1" を返します。

   バージョン 3.4 で追加.

PyStructSequence_Desc

   生成するstruct sequence 型のメタデータを保持します。

   +---------------------+--------------------------------+----------------------------------------+
   | フィールド          | C の型                         | 意味                                   |
   |=====================|================================|========================================|
   | "name"              | "const char *"                 | 生成するstruct sequence 型の名前       |
   +---------------------+--------------------------------+----------------------------------------+
   | "doc"               | "const char *"                 | pointer to docstring for the type or   |
   |                     |                                | "NULL" to omit                         |
   +---------------------+--------------------------------+----------------------------------------+
   | "fields"            | "PyStructSequence_Field *"     | 新しい型のフィールド名を格納した       |
   |                     |                                | "NULL" 終端された配列へのポインタ      |
   +---------------------+--------------------------------+----------------------------------------+
   | "n_in_sequence"     | "int"                          | Python 側で可視となるフィールドの数 (  |
   |                     |                                | もしタプルとして使用する場合)          |
   +---------------------+--------------------------------+----------------------------------------+

PyStructSequence_Field

   struct sequenceのフィールドについて記述します。struct sequence はタ
   プルをモデルにしているため、全てのフィールドは "PyObject*" として型
   付けされます。 "PyStructSequence_Desc" の "fields" 配列の添え字によ
   って struct sequenceのどのフィールドについて記載しているかが決まり
   ます。

   +-------------+--------------------+-------------------------------------------+
   | フィールド  | C の型             | 意味                                      |
   |=============|====================|===========================================|
   | "name"      | "const char *"     | name for the field or "NULL" to end the   |
   |             |                    | list of named fields, set to              |
   |             |                    | "PyStructSequence_UnnamedField" to leave  |
   |             |                    | unnamed                                   |
   +-------------+--------------------+-------------------------------------------+
   | "doc"       | "const char *"     | フィールドのdocstring、省略する場合は     |
   |             |                    | "NULL"                                    |
   +-------------+--------------------+-------------------------------------------+

char* PyStructSequence_UnnamedField

   フィールド名を名前がないままするための特殊な値。

PyObject* PyStructSequence_New(PyTypeObject *type)
    *Return value: New reference.*

   *type* のインスタンスを生成します。 *type* は
   "PyStructSequence_NewType()" によって事前に生成していなければなりま
   せん。

PyObject* PyStructSequence_GetItem(PyObject *p, Py_ssize_t pos)
    *Return value: Borrowed reference.*

   *p* の指すstruct sequence内の、位置 *pos* にあるオブジェクトを返し
   ます。境界チェックを行いません。

PyObject* PyStructSequence_GET_ITEM(PyObject *p, Py_ssize_t pos)
    *Return value: Borrowed reference.*

   "PyStructSequence_GetItem()" と同等のマクロです。

void PyStructSequence_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)

   struct sequence *p* の *pos* の位置にあるフィールドに値 *o* を設定
   します。"PyTuple_SET_ITEM()" のように、生成したてのインスタンスに対
   してのみ使用すべきです。

   注釈:

     この関数は *o* への参照を "盗み取り" ます。

void PyStructSequence_SET_ITEM(PyObject *p, Py_ssize_t *pos, PyObject *o)

   "PyStructSequence_SetItem()" と同等のマクロ。

   注釈:

     この関数は *o* への参照を "盗み取り" ます。
