数値型プロトコル (number protocol)
**********************************

int PyNumber_Check(PyObject *o)

   オブジェクト *o* が数値型プロトコルを提供している場合に "1" を返し
   、そうでないときには偽を返します。この関数呼び出しは常に成功します
   。

   バージョン 3.8 で変更: *o* がインデックス整数だった場合、 "1" を返
   します。

PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* を加算した結果を返し、失敗すると "NULL" を
   返します。Python の式 "o1 + o2" と同じです。

PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* から *o2* を減算した結果を返し、失敗すると "NULL"
   を返します。Python の式 "o1 - o2" と同じです。

PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* を乗算した結果を返し、失敗すると "NULL" を
   返します。Python の式 "o1 * o2" と同じです。

PyObject* PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* を行列乗算した結果を返し、失敗すると "NULL"
   を返します。 Python の式 "o1 @ o2" と同じです。

   バージョン 3.5 で追加.

PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   Return the floor of *o1* divided by *o2*, or "NULL" on failure.
   This is the equivalent of the Python expression "o1 // o2".

PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   Return a reasonable approximation for the mathematical value of
   *o1* divided by *o2*, or "NULL" on failure.  The return value is
   "approximate" because binary floating point numbers are
   approximate; it is not possible to represent all real numbers in
   base two.  This function can return a floating point value when
   passed two integers.  This is the equivalent of the Python
   expression "o1 / o2".

PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* を *o2* で除算した剰余を返し、失敗すると "NULL" を
   返します。Python の式 "o1 % o2" と同じです。

PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   組み込み関数 "divmod()" を参照してください。失敗すると "NULL" を返
   します。 Python の式 "divmod(o1, o2)" と同じです。

PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
    *Return value: New reference.*

   組み込み関数 "pow()" を参照してください。失敗すると "NULL" を返しま
   す。 Python の式 "pow(o1, o2, o3)" と同じです。 *o3* はオプションで
   す。 *o3* を無視させたいなら、 "Py_None" を入れてください (*o3* に
   "NULL" を渡すと、不正なメモリアクセスを引き起こすことがあります)。

PyObject* PyNumber_Negative(PyObject *o)
    *Return value: New reference.*

   成功すると *o* の符号反転を返し、失敗すると "NULL" を返します。
   Python の式 "-o" と同じです。

PyObject* PyNumber_Positive(PyObject *o)
    *Return value: New reference.*

   成功すると *o* を返し、失敗すると "NULL" を返します。Python の式
   "+o" と同じです。

PyObject* PyNumber_Absolute(PyObject *o)
    *Return value: New reference.*

   成功すると *o* の絶対値を返し、失敗すると "NULL" を返します。Python
   の式 "abs(o)" と同じです。

PyObject* PyNumber_Invert(PyObject *o)
    *Return value: New reference.*

   成功すると *o* のビット単位反転 (bitwise negation) を返し、失敗する
   と "NULL" を返します。Python の式 "~o" と同じです。

PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* を *o2* だけ左シフトした結果を返し、失敗すると
   "NULL" を返します。Python の式 "o1 << o2" と同じです。

PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* を *o2* だけ右シフトした結果を返し、失敗すると
   "NULL" を返します。Python の式 "o1 >> o2" と同じです。

PyObject* PyNumber_And(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* の "ビット単位論理積 (bitwise and)" を返し
   、失敗すると "NULL" を返します。Python の式 "o1 & o2" と同じです。

PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* の  "ビット単位排他的論理和 (bitwise
   exclusive or)" を返し、失敗すると "NULL" を返します。Python の式
   "o1 ^ o2" と同じです。

PyObject* PyNumber_Or(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* の "ビット単位論理和 (bitwise or)" を返し失
   敗すると "NULL" を返します。Python の式 "o1 | o2" と同じです。

PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* を加算した結果を返し、失敗すると "NULL" を
   返します。*o1* が *in-place* 演算をサポートする場合、in-place 演算
   を行います。Python の文 "o1 += o2" と同じです。

PyObject* PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* から *o2* を減算した結果を返し、失敗すると "NULL"
   を返します。*o1* が *in-place* 演算をサポートする場合、in-place 演
   算を行います。Python の文 "o1 -= o2" と同じです。

PyObject* PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* を乗算した結果を返し、失敗すると "NULL" を
   返します。*o1* が *in-place* 演算をサポートする場合、in-place 演算
   を行います。Python の文 "o1 *= o2" と同じです。

PyObject* PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* を行列乗算した結果を返し、失敗すると "NULL"
   を返します。 *o1* が *in-place* 演算をサポートする場合、 in-place
   演算を行います。 Python の文 "o1 @= o2" と同じです。

   バージョン 3.5 で追加.

PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* を *o2* で除算した切捨て値を返し、失敗すると "NULL"
   を返します。*o1* が *in-place* 演算をサポートする場合、in-place 演
   算を行います。Python の文 "o1 //= o2" と同じです。

PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   Return a reasonable approximation for the mathematical value of
   *o1* divided by *o2*, or "NULL" on failure.  The return value is
   "approximate" because binary floating point numbers are
   approximate; it is not possible to represent all real numbers in
   base two.  This function can return a floating point value when
   passed two integers.  The operation is done *in-place* when *o1*
   supports it. This is the equivalent of the Python statement "o1 /=
   o2".

PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* を *o2* で除算した剰余を返し、, 失敗すると "NULL"
   を返します。*o1* が *in-place* 演算をサポートする場合、in-place 演
   算を行います。Python の文 "o1 %= o2" と同じです。

PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
    *Return value: New reference.*

   組み込み関数 "pow()" を参照してください。失敗すると "NULL" を返しま
   す。 *o1* が *in-place* 演算をサポートする場合、in-place 演算を行い
   ます。この関数は *o3* が "Py_None" の場合は Python 文 "o1 **= o2"
   と同じで、それ以外の場合は "pow(o1, o2, o3)" の in-place 版です。
   *o3* を無視させたいなら、 "Py_None" を入れてください (*o3* に
   "NULL" を渡すと、不正なメモリアクセスを引き起こすことがあります)。

PyObject* PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* を *o2* だけ左シフトした結果を返し、失敗すると
   "NULL" を返します。*o1* が *in-place* 演算をサポートする場合、in-
   place 演算を行います。Python の文 "o1 <<= o2" と同じです。

PyObject* PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* を *o2* だけ右シフトした結果を返し、失敗すると
   "NULL" を返します。*o1* が *in-place* 演算をサポートする場合、in-
   place 演算を行います。Python の文 "o1 >>= o2" と同じです。

PyObject* PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* の "ビット単位論理積 (bitwise and)" を返し
   、失敗すると "NULL" を返します。*o1* が *in-place* 演算をサポートす
   る場合、in-place 演算を行います。Python の文 "o1 &= o2" と同じです
   。

PyObject* PyNumber_InPlaceXor(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* の "ビット単位排他的論理和  (bitwise
   exclusive or)" を返し、失敗すると "NULL" を返します。*o1* が *in-
   place* 演算をサポートする場合、in-place 演算を行います。Python の文
   "o1 ^= o2" と同じです。

PyObject* PyNumber_InPlaceOr(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   成功すると *o1* と *o2* の "ビット単位論理和 (bitwise or)" を返し失
   敗すると "NULL" を返します。*o1* が *in-place* 演算をサポートする場
   合、in-place 演算を行います。Python の文 "o1 |= o2" と同じです。

PyObject* PyNumber_Long(PyObject *o)
    *Return value: New reference.*

   成功すると *o* を整数に変換したものを返し、失敗すると "NULL" を返し
   ます。Python の式 "int(o)" と同じです。

PyObject* PyNumber_Float(PyObject *o)
    *Return value: New reference.*

   成功すると *o* を浮動小数点数に変換したものを返し、失敗すると
   "NULL" を返します。Python の式 "float(o)" と同じです。

PyObject* PyNumber_Index(PyObject *o)
    *Return value: New reference.*

   *o* をPythonのint型に変換し、成功したらその値を返します。失敗したら
   "NULL" が返され、 "TypeError" 例外が送出されます。

PyObject* PyNumber_ToBase(PyObject *n, int base)
    *Return value: New reference.*

   *base* 進数に変換された整数 *n* を文字列として返します。 *base* 引
   数は2, 8, 10または16のいずれかでなければなりません。  基数2、8、16
   について、返される文字列の先頭には基数マーカー "'0b'" 、 "'0o'" ま
   たは "'0x'" が、それぞれ付与されます。  もし *n* が Python のint型
   でなければ、まず "PyNumber_Index()" で変換されます。

Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc)

   Returns *o* converted to a "Py_ssize_t" value if *o* can be
   interpreted as an integer.  If the call fails, an exception is
   raised and "-1" is returned.

   If *o* can be converted to a Python int but the attempt to convert
   to a "Py_ssize_t" value would raise an "OverflowError", then the
   *exc* argument is the type of exception that will be raised
   (usually "IndexError" or "OverflowError").  If *exc* is "NULL",
   then the exception is cleared and the value is clipped to
   "PY_SSIZE_T_MIN" for a negative integer or "PY_SSIZE_T_MAX" for a
   positive integer.

int PyIndex_Check(PyObject *o)

   Returns "1" if *o* is an index integer (has the "nb_index" slot of
   the "tp_as_number" structure filled in), and "0" otherwise. This
   function always succeeds.
