G
G
golub4ik2018-07-14 05:37:39
Python
golub4ik, 2018-07-14 05:37:39

Python, tell us a little about speed?

I'm testing something here, explain why the speed varies so much (errors on average + -0.1 sec)
1. Average replenishment time 3.3 - 3.5

string = "123"
result = 0
for i in range(10000000):
 result = int(string)

2.2.6 - 2.8
string = "123"
result = 0
def main():
    for i in range(10000000):
        result = int(string)
main()

3.2.4 - 2.6
string = "123"
result = 0
def main():
    for i in range(10000000):
        result = int(string)
if __name__ == '__main__':
    main()

I'm still a noob, can you tell me a little about it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question