If I run, assuming e
is a large value like 65537
:
x**e
It takes a very long time, however assuming a reasonable n
:
(x**e)%n
Runs much faster, so Python is clearly optimising modular exponentiation. My question is how does CPython identify that it can make this optimisation, is it the bytecode or something else?