How To Make Your Python Packages Really Fast With RUST

preview_player
Показать описание
Everyone knows that program speed isn't Python's strong point. That's why so many number-crunching data science libraries are written in C.

BUT C can cause headaches. Segfaults are common and memory leaks are something to be feared. What if there was another option? Well, there is. It's Rust. Rust is a blazingly fast, memory-efficient and memory-safe language that's an absolute joy to work with. And I'm going to teach you how to use it to write your Python packages.

Check out the code:

Resources:

__________________________________________

Check out my other socials!
__________________________________________

Timestamps:
00:00 - Introduction and explanation
00:46 - Prerequisites
00:58 - Script overview
01:19 - Maturin setup
02:09 - Writing the Rust
02:53 - Benchmarking our function
04:08 - Rust limitations
04:43 - Common gotchas

#python #softwareengineer #rust
Рекомендации по теме
Комментарии
Автор

"C has enough foot guns to cripple a centipede..." 🙂

yadukrishnan
Автор

ERRATA:

4:24 - You can use a u64 on a 32-bit machine! The compiler will do its magic and sort it all out for you.

IsaacHarrisHolt
Автор

Damn, after getting more comfortable with the idea of calling opencl code from either python or rust, or c code from python, wrangling c types in all cases, I've been meaning to get to calling rust from python, did not realise it can be this easy (especially for end users too), this might be exactly what I wanted, you've saved me some research :).

I kinda like c, but I do find myself missing generics, traits and maybe sum types and pattern matching, not super fussed about automatically checked safety, you still end up having to think about what needs to be accessed from where (and apart from rust-gpu, we still don't really have this for GPGPU), but hey, automating some of that with the compiler can't be a bad thing. All in all, looking forward to using rust for more stuff, apart from when I would find a repl more convenient (data analysis and plotting). Knowing what functions can and can't fail and where you might have to think about nulls is also pretty cool.

johanngambolputty
Автор

Why are you so underrated. You have genuinely good content, why are you still don't get any views? Keep going, good content!

LowRezCat
Автор

There are a lot of videos on this topic but this one earns a like for being focused and to the point. Thanks 🙏

AkilManivannan
Автор

Great video! I wonder what packages I'm already using are actually written in Rust.

mCoding
Автор

Amazing video. You deserve more subscribers than mr beast.

filipengstrom
Автор

don't know about it. there are good, tested modules like numpy, to make your counts in python, they are fast.

bogaczew
Автор

So informative! thank u!
I can really tell that this vid was made with love <3

ofeki
Автор

I'm curious by your comment on "u64 might not be supported on every machine". What about u128? I am sure this is more than enough for 99.9% of use-cases.

ErikCampobadal
Автор

I try learn Julia but there are only English resources

archniki_
Автор

This is good for rust developers but not C or C++ for obvious reasons.
anything that enriches python echo system is welcomed by me.

amortalbeing
Автор

What are you talking about? u64 and u128 are supported in 32 bit machines lol, the compiler fixes that for you. Please add this correction as that is highly misleading.

That being said, it's very rare to build for a 32 bit architecture in 2023 if you're not in embedded, and there you have a whole lot of other things to worry about.

CamaradaArdi
Автор

C can be fun. It is super simple once you get the hang of it.

quintencabo
Автор

Better use something more similar to Pyrhon and easier like cython or for instance D or nim..

pablodenapoli
Автор

I'm both a python (on job) and a rust (newbie and hobby) programmer. And before I start my criticism: Yes, pure python code will be slower than rust code most of the time.

My issue is the abundance of oversimplified benchmarks on the internet like this one. Please stop doing those. New programmers will pick up those examples and will think these are mostly okay. Please, use real-world problems whenever possible and solve it with your best effort on both sides. Don't trust the results and don't jump on conclusions. Verify the results as good as you can and be as transparent as possible when publishing the results.

PaulJaros
Автор

Hey great tutoriel sadly the command maturin doesnt seem to work. My maschine cant find a cmdlet, function, script or executable Program named Maturin. Maturin is installed with pip just like you did in the tutoriel. Thanks for your time and help.❤

hanshosel
Автор

C++ has enough leg bombs to cripple a tank

yash
Автор

When i run "maturin init" it says
error: unrecognized subcommand 'init'

I am using kubuntu. Any idea whats going on?

TheArchCoder
Автор

Why would you recommend Rust for someone with Python background and not Nim?

KrzysztofDerecki