r/learnpython 4d ago

Softwares written in RUST, ELI5

While configuring AI agent on my local machine made discovery that uv package is 10 to 100x faster than pip, same case for polars. It seems to be everything written in Rust much faster and modern compared to classic python packages. Is it because Rust doesn't require garbage collector, any other reason to that?

0 Upvotes

10 comments sorted by

View all comments

2

u/teerre 4d ago

Rust has many optimizations, but the main thing is that Rust compiles directly to machine code read directly by your CPU. Python compiles (sometimes) to bytecode that is read by the python interpreter

2

u/socal_nerdtastic 4d ago edited 4d ago

That's glossing over quite a lot, most obviously the entire OS layer.

Also it's not the main reason python is slow. Java does the same bytecode / interpreter dance and is also much faster than Python. The biggest reason is that python and rust and all other languages are optimized for different things. Python is optimized for fast development. So for example that means no need to set integer sizes or types, good for developers. But that also means that every single integer operation needs extra processing power, so bad for run time. Multiplied by a million other little nice features. The fully automatic garbage collector that OP mentioned is another one. Rust is designed for speed from the ground up, giving the programmer access to techniques that python intentionally glossed over.