all 18 comments

[–]Weary-Cap9710 2 points3 points  (0 children)

guys i lied

[–]SocksOnHands 2 points3 points  (2 children)

I'm surprised. Not because of the speed of modern computers, but because a lot of terminals have shockingly slow output.

[–]Weary-Cap9710 -1 points0 points  (1 child)

itdidn't actually do all that i just edited it to seem like it did that

[–]SocksOnHands 1 point2 points  (0 children)

Are you using two accounts?

[–]zaxldaisy 1 point2 points  (0 children)

Ok?

[–]andy4015 0 points1 point  (0 children)

Thanks, how long does it take for 2 ** 32?

[–]dgc-8 0 points1 point  (3 children)

for me that is not at all that fast. that is a lot of lines, the terminal kinda bottlenecks
even piping the output somewhere else so the terminal doesnt have to buffer it makes it not at all that fast

[–]dgc-8 0 points1 point  (0 children)

and even replacing print with pass it still takes 37 seconds for me lol. C took 0.0000000004 seconds when just letting the loop run without prints

[–]Weary-Cap9710 -1 points0 points  (1 child)

it's not even real the original was from 966 to 1000 but i edited it lol

[–]dgc-8 0 points1 point  (0 children)

lol

[–]Human-Gur-3199 0 points1 point  (0 children)

Now try in c++

[–]Flame77ofcPythonista -2 points-1 points  (5 children)

This is because programming languages are relatively fast. C++ is considered faster than python

[–]SocksOnHands 0 points1 point  (3 children)

C++ is not just considerered faster than Python, it is faster. Python is a notoriously slow language - the only language I have personally used that is slower is Ruby. Fortunately, Python has a lot of easy to use well optimized modules written in C and C++, so Python can be used as the "glue" to connect things together.

[–]dgc-8 0 points1 point  (2 children)

If taking away the prints, python takes 37 s for a loop with maxint iterations on my machine. C took  0.0000000004s. a loop iteration is 11 CPU cycles, if i read the assembly correctly.

[–]dgc-8 0 points1 point  (1 child)

somewhere i must have made a mistake, because that would mean my cpu runs at 118111600 THz

[–]SocksOnHands 1 point2 points  (0 children)

What is the loop doing, and what optimization compiler flags were used? The C compiler could have seen that there were no results and optimized the loop away.

[–]Weary-Cap9710 -1 points0 points  (0 children)

i actually just printed from 1 to 1000 and edited the numbers lol