I have a question, why python numeric calculation is very fast?
for example the below code runs shorter than one second
import math
print math.factorial(10000)
why???
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
mathmodule’s functions are implemented in C:By using an efficient algorithm in C, you get fast results.
If you are asking why this particular operation is so fast, then see Why is math.factorial much slower in Python 2.x than 3.x? and the C code itself.