some types, such as ints, are able to use a more efficient algorithm when invoked using the three-argument form.
某些类型(例如 int)在调用三参数形式pow(base, exp, mod)
时,能够使用更高效的算法。
“更高效的算法”指什么?
base ** exp % mod
会先生成一个巨大整数,再做取模;
一句话记忆
pow
传第三个参数 mod
,Python 会自动切换到快速模幂算法,又省内存又省时间。