I switched to c++ because i heard its 400 times faster than python, But when i made an infinite loop that increments a variable and prints its value python seems to be faster, How can that be? And how to optimize it?
Python script:
x = 1
while 1:
print(x)
x+=1
C++ code:
int x = 1;
while (1) {
cout << x << endl;
x++;
}
I tried optimizing it by putting this command:
ios_base::sync_with_stdio(false);
The speed became almost identical to python's but not faster.
Yeah and i did search for this topic i didn't find anything that explains why.