Can Go really be that much faster than Python?

前端 未结 8 1412
抹茶落季
抹茶落季 2021-01-31 14:27

I think I may have implemented this incorrectly because the results do not make sense. I have a Go program that counts to 1000000000:

package main

import (
             


        
8条回答
  •  一整个雨季
    2021-01-31 15:16

    It is possible that the compiler realized that you didn't use the "i" variable after the loop, so it optimized the final code by removing the loop.

    Even if you used it afterwards, the compiler is probably smart enough to substitute the loop with

    i = 1000000000;
    

    Hope this helps =)

提交回复
热议问题