Python vs Rust vs C++ Speed Comparison

preview_player
Показать описание
This is a debug build speed comparison test, where the program calculates all prime numbers in the range of 1-100000. I used PyCharm for Python, CLion for C++ and RustRover for Rust.

Sound effects by Senna and Otto from Pixabay
Рекомендации по теме
Комментарии
Автор

Great post! Just to add on, as someone already mentioned, it's best to compare production-ready builds. On my machine, Rust in debug mode runs at 1.6s (similar to your results), but in release mode, it finishes in 0.2s—about 8x faster!

TommyLeeBlaze
Автор

rust debug mode is very slow because rust does far more checks in the run time, run rust with all optimizations enabled and in release mode then test the speed

wassim-akkari
Автор

How fast you can type out the code is a useless metric.

dyn
Автор

C++ performance depends on settings, optimization and compilers. If you twist the C++ ear or bite the tail, then see what happens?. 🌹🌹👌👌

Ekalai
Автор

Suggestion: to completely remove the impacts (if any) of time measurement across languages, I would measure the execution time in the shell instead.

johnnybueti
Автор

Learn C/CPP from top to bottom, from inner to out and you will solve 90% of the tasks.

softwaremkxvii
Автор

Change algo to only count to sqrt the number, that is the highest factor. Save that to a variable for the check on the for loop. The compiler should optimise it, just double check.

veritasliberabitvos
Автор

why not run cargo with --release flag?

On my machine in debug mode it takes 2 seconds and in release mode it ran about 0.8 seconed. on the other hand C++ in -Ofast flag takes 0.851 second which is little slower than rust.

urparvezali
Автор

The C++ code turned out to be cumbersome, it must be done in C, the printf function is simpler.

LithiumDeuteride-
Автор

What the hell kind of comparison are you making? Python is an interpreted language, while Rust and C++ are compiled languages!

andreasalvi
Автор

Hi! Enable multithreading in Python 3.13 and do a speed comparison Python 3.12 vs Python 3.13.

ukrainian-playlists
Автор

Yup python takes least human time. Python is most performant.

tickshot
Автор

Nice, but you've lost the great opportunity of running Rust and C++ in release mode afterward, with all optimizations enabled, and actually comparing the speed of both compiled languages in this case.

rsalmei
Автор

rust without iterators and debug mode :(

julyort
Автор

I heard on the grapevine that pypy is faster, that its speed is comparable with c++

IorPerry
Автор

I just tried to do this in Kotlin for fun and I got...

"Found 9592 primes in 0.841438700 seconds".

Can anyone tell me why so? I did similar tests with Java/Kotlin/C++ about a year ago and found that in some cases C++ is even slower than Java or Kotlin. Is the speed of low-level languages ​​a conspiracy theory?

babananick
Автор

What a joke of a video, I thought they were about to compare the execution speed, who the f cares about this

leotravel
Автор

Man, i really hate the FAKE KEYBOARD SOUND, use instead some music idk but man, that sound is awful cringe

UltimatusVirsus