Python vs C++: For Loop Speed Test #coding #python #cpp

preview_player
Показать описание
Just a fun speed test comparing Python and C++ with a simple for loop. Guess which one's faster? 👀
Not scientific, just for laughs 😄
#Programming #Python #CPP #PerformanceTest #CodeBattle #DevHumor #ForLoop #SpeedTest
Рекомендации по теме
Комментарии
Автор

Disclaimer: This was just for fun! I know this isn't a scientifically rigorous benchmark — just a casual test. Please don’t take it too seriously (or personally 😅). Real performance depends on context, optimization, and what you’re doing. Peace ✌️

Dev_with_Sel
Автор

Updated test results!
Python: 0.295956 seconds
C++ (no optimizations): 0.0309341 seconds
C++ with -O2: seconds (that’s 126 nanoseconds!)

The “2.2 million times faster” claim was mostly a joke — the compiler completely optimized the loop away with -O2, so that result isn't real.
A more reasonable comparison is:
0.295956 / 0.0309341 ≈ 9.56x faster, which actually makes sense.

Next time I’ll use volatile or some dummy operation to prevent the loop from disappearing 😄

Dev_with_Sel
join shbcf.ru