|
|
@ -608,39 +608,45 @@ PyDoc_STRVAR(builtin_ord__doc__, |
|
|
{"ord", (PyCFunction)builtin_ord, METH_O, builtin_ord__doc__}, |
|
|
{"ord", (PyCFunction)builtin_ord, METH_O, builtin_ord__doc__}, |
|
|
|
|
|
|
|
|
PyDoc_STRVAR(builtin_pow__doc__, |
|
|
PyDoc_STRVAR(builtin_pow__doc__, |
|
|
"pow($module, x, y, z=None, /)\n" |
|
|
|
|
|
|
|
|
"pow($module, /, base, exp, mod=None)\n" |
|
|
"--\n" |
|
|
"--\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"Equivalent to x**y (with two arguments) or x**y % z (with three arguments)\n" |
|
|
|
|
|
|
|
|
"Equivalent to base**exp (with two arguments) or base**exp % mod (with three arguments)\n" |
|
|
"\n" |
|
|
"\n" |
|
|
"Some types, such as ints, are able to use a more efficient algorithm when\n" |
|
|
"Some types, such as ints, are able to use a more efficient algorithm when\n" |
|
|
"invoked using the three argument form."); |
|
|
"invoked using the three argument form."); |
|
|
|
|
|
|
|
|
#define BUILTIN_POW_METHODDEF \ |
|
|
#define BUILTIN_POW_METHODDEF \ |
|
|
{"pow", (PyCFunction)(void(*)(void))builtin_pow, METH_FASTCALL, builtin_pow__doc__}, |
|
|
|
|
|
|
|
|
{"pow", (PyCFunction)(void(*)(void))builtin_pow, METH_FASTCALL|METH_KEYWORDS, builtin_pow__doc__}, |
|
|
|
|
|
|
|
|
static PyObject * |
|
|
static PyObject * |
|
|
builtin_pow_impl(PyObject *module, PyObject *x, PyObject *y, PyObject *z); |
|
|
|
|
|
|
|
|
builtin_pow_impl(PyObject *module, PyObject *base, PyObject *exp, |
|
|
|
|
|
PyObject *mod); |
|
|
|
|
|
|
|
|
static PyObject * |
|
|
static PyObject * |
|
|
builtin_pow(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
|
|
|
|
|
|
|
|
builtin_pow(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
|
|
{ |
|
|
{ |
|
|
PyObject *return_value = NULL; |
|
|
PyObject *return_value = NULL; |
|
|
PyObject *x; |
|
|
|
|
|
PyObject *y; |
|
|
|
|
|
PyObject *z = Py_None; |
|
|
|
|
|
|
|
|
|
|
|
if (!_PyArg_CheckPositional("pow", nargs, 2, 3)) { |
|
|
|
|
|
|
|
|
static const char * const _keywords[] = {"base", "exp", "mod", NULL}; |
|
|
|
|
|
static _PyArg_Parser _parser = {NULL, _keywords, "pow", 0}; |
|
|
|
|
|
PyObject *argsbuf[3]; |
|
|
|
|
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
|
|
|
|
|
PyObject *base; |
|
|
|
|
|
PyObject *exp; |
|
|
|
|
|
PyObject *mod = Py_None; |
|
|
|
|
|
|
|
|
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); |
|
|
|
|
|
if (!args) { |
|
|
goto exit; |
|
|
goto exit; |
|
|
} |
|
|
} |
|
|
x = args[0]; |
|
|
|
|
|
y = args[1]; |
|
|
|
|
|
if (nargs < 3) { |
|
|
|
|
|
goto skip_optional; |
|
|
|
|
|
|
|
|
base = args[0]; |
|
|
|
|
|
exp = args[1]; |
|
|
|
|
|
if (!noptargs) { |
|
|
|
|
|
goto skip_optional_pos; |
|
|
} |
|
|
} |
|
|
z = args[2]; |
|
|
|
|
|
skip_optional: |
|
|
|
|
|
return_value = builtin_pow_impl(module, x, y, z); |
|
|
|
|
|
|
|
|
mod = args[2]; |
|
|
|
|
|
skip_optional_pos: |
|
|
|
|
|
return_value = builtin_pow_impl(module, base, exp, mod); |
|
|
|
|
|
|
|
|
exit: |
|
|
exit: |
|
|
return return_value; |
|
|
return return_value; |
|
|
@ -849,4 +855,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
|
|
exit: |
|
|
exit: |
|
|
return return_value; |
|
|
return return_value; |
|
|
} |
|
|
} |
|
|
/*[clinic end generated code: output=4e118c2cd2cd98f3 input=a9049054013a1b77]*/ |
|
|
|
|
|
|
|
|
/*[clinic end generated code: output=1e2a6185e05ecd11 input=a9049054013a1b77]*/ |