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

int PyNumber_Check(PyObject *o)

   オブジェクト *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_Divide(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   Returns the result of dividing *o1* by *o2*, or *NULL* on failure.
   This is the equivalent of the Python expression "o1 / o2".

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

   成功すると *o1* を *o2* で除算した切捨て値を返し、失敗すると *NULL*
   を返します。」旧仕様の」 整数間での除算と同じです。

   バージョン 2.2 で追加.

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

   成功すると、数学的な *o1* の *o2* による除算値に対する妥当な近似
   (reasonable approximation) を返し、失敗すると *NULL* を返します。全
   ての実数を 2 を基数として表現するのは不可能なため、二進の浮動小数点
   数は 「近似値」 しか表現できません。このため、戻り値も近似になりま
   す。この関数に二つの整数を渡した際、浮動小数点の値を返すことがあり
   ます。

   バージョン 2.2 で追加.

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_InPlaceDivide(PyObject *o1, PyObject *o2)
    *Return value: New reference.*

   Returns the result of dividing *o1* by *o2*, or *NULL* on failure.
   The operation is done *in-place* when *o1* supports it. This is the
   equivalent of the Python statement "o1 /= o2".

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

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

   バージョン 2.2 で追加.

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

   成功すると、数学的な *o1* の *o2* による除算値に対する妥当な近似
   (reasonable approximation) を返し、失敗すると *NULL* を返します。全
   ての実数を 2 を基数として表現するのは不可能なため、二進の浮動小数点
   数は 「近似値」 しか表現できません。このため、戻り値も近似になりま
   す。この関数に二つの整数を渡した際、浮動小数点の値を返すことがあり
   ます。*o1* が *in-place* 演算をサポートする場合、in-place 演算を行
   います。

   バージョン 2.2 で追加.

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" と同じです。

int PyNumber_Coerce(PyObject **p1, PyObject **p2)

   This function takes the addresses of two variables of type
   "PyObject*". If the objects pointed to by "*p1" and "*p2" have the
   same type, increment their reference count and return "0"
   (success). If the objects can be converted to a common numeric
   type, replace "*p1" and "*p2" by their converted value (with 『new
   』 reference counts), and return "0". If no conversion is possible,
   or if some other error occurs, return "-1" (failure) and don’t
   increment the reference counts.  The call "PyNumber_Coerce(&o1,
   &o2)" is equivalent to the Python statement "o1, o2 = coerce(o1,
   o2)".

int PyNumber_CoerceEx(PyObject **p1, PyObject **p2)

   This function is similar to "PyNumber_Coerce()", except that it
   returns "1" when the conversion is not possible and when no error
   is raised. Reference counts are still not increased in this case.

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

   Returns the *o* converted to an integer object on success, or
   *NULL* on failure. If the argument is outside the integer range a
   long object will be returned instead. This is the equivalent of the
   Python expression "int(o)".

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

   Returns the *o* converted to a long integer object on success, or
   *NULL* on failure.  This is the equivalent of the Python expression
   "long(o)".

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

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

PyObject* PyNumber_Index(PyObject *o)

   Returns the *o* converted to a Python int or long on success or
   *NULL* with a "TypeError" exception raised on failure.

   バージョン 2.5 で追加.

PyObject* PyNumber_ToBase(PyObject *n, int base)

   Returns the integer *n* converted to *base* as a string with a base
   marker of "'0b'", "'0o'", or "'0x'" if applicable.  When *base* is
   not 2, 8, 10, or 16, the format is "'x#num'" where x is the base.
   If *n* is not an int object, it is converted with
   "PyNumber_Index()" first.

   バージョン 2.6 で追加.

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 *o* can be converted to a Python int
   or long 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.

   バージョン 2.5 で追加.

int PyIndex_Check(PyObject *o)

   *o* がインデックス整数である場合 (tp_as_number構造体のnb_indexスロ
   ットが埋まっている場合) に "1" を返し、そうでない場合に "0" を返し
   ます。

   バージョン 2.5 で追加.
