I feel that python is slow.
When I executed the for statement, it didn't end easily.
What should I do if I don't know the cause?

time1 = time.time ()
for i in range (10000):
    print (i)
print (time.time ()-time1)
# 2.1952428817749023
  • Answer # 1

    The slowest is print. Console screen input/output is a very heavy process, so it takes some time to go in any language.

    If possible, output to a file instead of a screen.

    For Python, in addition to that, for is also slow, so it will be a little faster if you first assemble the string with comprehensions.

  • Answer # 2

    It was 0.6711642742156982 when I executed it with Spyder at hand.
    ... I don't think it's slow

    Python 3.7.5, Linux Mint19.2, AMD Ryzen 5 1600X

  • Answer # 3

    python is an interpreter.
    That's slow