We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Rust and Python

00:00

Formale Metadaten

Titel
Rust and Python
Untertitel
Oxidize Your Snake
Serientitel
Anzahl der Teile
132
Autor
Lizenz
CC-Namensnennung - keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben
Identifikatoren
Herausgeber
Erscheinungsjahr
Sprache

Inhaltliche Metadaten

Fachgebiet
Genre
Abstract
Rust is a safe and modern systems programming language that is easily able to call and be called from Python. As such, it is a prime candidate for replacing C for writing Python modules that have to be fast or that have to interact with other native code. Rust is extremely fast and makes it very hard to get concurrency wrong. Many ways of making Python call into lower level have appeared over the years such as CFFI, ctypes, boost.python, cython, SWIG. All of them are cumbersome in their own ways. PyO3 is a Rust library that makes it easy and simple to write native Python modules with minimal glue code and no crazy tooling required. It even works cross-platform without problems. The talk shows some sample code of PyO3-based modules and compares it with the code of the alternatives as well as the alternative's cross-platform support and tooling. The goal is for the audience to be informed about a new safe and modern way of writing native Python modules. The audience doesn't need any prerequisites except for a healthy interest in native code and Python modules. C knowledge is optional.
35
74
Vorschaubild
11:59
MaßerweiterungJust-in-Time-CompilerStrom <Mathematik>DefaultComputervirusNormierter RaumZeichenketteKlasse <Mathematik>BildschirmsymbolToken-RingCodeSchätzungZufallszahlenPhysikalisches SystemTotal <Mathematik>MultiplikationAlgorithmusCachingMultigraphVersionsverwaltungDesintegration <Mathematik>RechenschieberRechenwerkInnerer PunktProgrammbibliothekHalbleiterspeicherBridge <Kommunikationstechnik>Rechter WinkelBimodulSnake <Bildverarbeitung>Case-ModdingSystemaufrufFunktionalZeichenketteProgrammierungSystemzusammenbruchDefaultMultiplikationsoperatorFehlermeldungBitCompilerResultanteSymboltabelleKlasse <Mathematik>SoftwareMathematische LogikDatenverwaltungHyperbelverfahrenIterationEDV-BeratungInstantiierungDifferentePolygonnetzTextbausteinOrdnung <Mathematik>TypentheorieRandomisierungMultiplikationDynamisches SystemTabelleWasserdampftafelImplementierungVersionsverwaltungMultigraphMusterspracheMAPPerspektiveSchnelltasteMakrobefehlCASE <Informatik>Zufallsgeneratorp-BlockDatenstrukturDialektKonstruktor <Informatik>SchnittmengePi <Zahl>EinsObjekt <Kategorie>BeobachtungsstudieMailing-ListeSoftwareentwicklerHochdruckAggregatzustandGenerator <Informatik>KonditionszahlDatenparallelitätVariableZeiger <Informatik>ThreadMinkowski-MetrikDickeDateiformatEinfacher RingSchreiben <Datenverarbeitung>Just-in-Time-CompilerInterpretiererLambda-KalkülMaßerweiterungWort <Informatik>Ganze FunktionAuswahlaxiomPhysikalisches SystemCharakteristisches PolynomLeistung <Physik>Patch <Software>Spannweite <Stochastik>Produkt <Mathematik>PunktProxy ServerBefehl <Informatik>ComputersicherheitSummierbarkeitKreisflächeElektronische PublikationAlgorithmische ProgrammierspracheRechenbuchMessage-PassingMapping <Computergraphik>TemplateVektorraumBinärcodeZweiRichtungDreiBitmap-GraphikGeradeMathematikBildgebendes VerfahrenTopologieKategorie <Mathematik>Lipschitz-StetigkeitArray <Informatik>BenutzerschnittstellenverwaltungssystemUniformer RaumExpertensystemGlobale OptimierungCodeParallele SchnittstelleBrowserZählenServerSpeicherabzugOrtsoperatorWhiteboardZahlenbereichFunktion <Mathematik>HardwareLaufzeitfehlerAbstraktionsebeneRechenschieberBrennen <Datenverarbeitung>NormalvektorWechselseitiger AusschlussStandardabweichungFitnessfunktionGRASS <Programm>SoftwaretestComputerarchitekturComputerforensikEin-AusgabeUnrundheitFormation <Mathematik>DämpfungMomentenproblemOverhead <Kommunikationstechnik>Güte der AnpassungSchaltnetzFaserbündelProgrammierumgebungProjektive EbeneComputerspielNotebook-ComputerEinfache GenauigkeitTaskVirtuelle MaschineStrömungsrichtungIntegralSpeicherverwaltungMaschinencodeProgrammierspracheDatentypObjektorientierte ProgrammierspracheLesen <Datenverarbeitung>Abgeschlossene MengeUnicodeFormale SpracheAlgorithmusTranslation <Mathematik>Puls <Technik>KalkülZellularer AutomatWarteschlangeAttributierte GrammatikComputervirus
Transkript: Englisch(automatisch erzeugt)
All right, so hello everybody you can call me Sven and for for money stuff I do basically I'm a freelance software consultant, but for you know for fun stuff. I do rust and a fair bit of that and Yeah, so today
I'm going to show you How to use rust in order to speed up your Python also how to use Python or to slow down your rust I'm serious. Actually. We're gonna look into that and Yeah, let's get started now actually as far as the conference goes I'm fairly surprised because there were like three rest talks already I believe like this was fairly surprising because like last year there was nothing and so I'm quite glad that you know
This is kind of working out for us Right, so But I like I believe that I'm presenting a new method that hasn't been brought up in this conference before and I believe it's quite quite simple and quite low on boilerplate, so Yeah, let's dive just into it. And also I'm gonna assume that you have no knowledge of rust whatsoever
I believe the other talks kind of assumed that you did I'm gonna explain every little bit of syntax And in fact, we're gonna look into you know, what rust looks like first And then we're gonna discuss the more interesting concepts All right So first of all gonna talk about the motivation like there's different like reasons for why you would want to use rust to begin with Right, there's different reasons now I'm gonna look at the current approaches in order to fulfill some of these motivations and then
we're gonna see how we can actually fulfill the Motivation using rust and then let's see what we can you know, take away from the from this talk All right So there might be multiple military motivations why you might want to do this now, obviously the first like the most Intriguing one of them highest impact one is take to speed up your program, right?
This is always the like the primary reason but you might also want to escape the Jill or at the gill In order to do some proper multi-threading right because we all know that in Python You can't do proper multi-threading without kind of running some hoops around places and also might want to bind to exist in system libraries For instance, if you have like if you're a scientist, right you want to build bind to some exist in C++ libraries
This might be a thing that you might want to use like rest for for building some kind of like the the glue code Right. So today we're only gonna explore the speed up your program kind of thing because I also got the vibe from the conference This is probably the most important topic for everybody
Because you know Python is kind of slow right and we want to make it kind of fast and now the questions how do we get there? All right, but Let's let's see how we can like which ways currently exists in order to speed up our Python and as far as that is Concerned we are we know very well about these C extensions. Of course, like this is probably the best documented way
But to be honest, they're quite annoying right that you have to write lots of boilerplate code You know, it's not very not very nice All right, then there are C types which is kind of the the newer way to do that But you know, it's kind of discouraged nowadays and then there's CFFI which is like probably the newest way to do that But you know, it's also kind of boilerplate heavy and I don't like that. So there's
Binding generators like boost Python which you know if it works, it's fine, right? But if it doesn't work you get like megabytes of template messages in C++, which is not very nice and you have SWIC Which also generates Python bindings Then a specialized libs which you can use like pillow for it for image manipulation for instance or numpy
Which I'm sure many are familiar with which you can also use to vectorize your code And if you can fit it into that, it's great and you should probably just kind of keep it that but sometimes You just can't and you have to be you know, we have to be a bit more ingenious about that And then of course there's PyPy which we all know enough Which is a JIT based approach to speeding up the program and the best case
Of course, you don't have to do anything, which is also great and then there's Cython which is a Python dialect, of course And then there is another binding generator on the block It's Python 3 and this is actually what we're gonna be using which is a Rust based Python kind of binding generator
Alright, let's look at why we would actually want to like approach and this thing from a new perspective, right? So like why do we even care so current approaches like at least the manual ones are unsafe and unsafe I mean that you might run into data concurrency issues Like you were at run into race conditions dirty read study write stuff like that
Right, if you have multiple threads writing the same variable like what you're gonna do So you're gonna have to handle that you don't like especially in C, right? You're gonna have to use your own memory management Which is not very nice and you might run into segmentation faults or like You know uninitialized memory stuff like that. So we don't like that right now C is not very economic either, right?
It's you know showing its age, right? Like it doesn't have very nice syntax for for solving some concepts. Like it doesn't have nice lambda syntax You can kind of do it right, but it's not really nice. Then you have G object, which is also very nice So right, it's not really nice. So and then if you we use pi pi, right?
Using a JIT based approach. It's kind of unreliable, right? You might it might work. It might not work Doesn't play so nice with C type either. So not really great either Multithreading as I just said like C and multithreading is not the greatest, you know of words right now It's you can't do it But to be honest like yeah Like this would probably not be your best choice if you were to speed up your program program using that
So instead we're gonna oxidize Or snake or your snake essentially, so we're gonna use Python and Rust in order to make an oxidized snake get it It's like a snake, but it's oxidized, okay Alright so
What is Rust? As I said, I'm gonna assume that you have no idea about Rust and this is totally fine because of the Python conference Alright, so Rust is safe. You're not gonna get any problems with like data races. You're not gonna get any initialized memory basically, there's Like it's very hard for you to crash your program to be quite honest, right? you can make it unsafe, but you have to be very explicit about it and
Yeah, the compiler is actually a bit of a bitch about it to be honest Like the you're gonna spend a lot of time fighting the compiler But in the end if it does compile you can be reasonably sure that at least it won't crash, right? I mean, of course, you can still make logic issues, right? But no programming language probably ever is gonna save you from those, right? So
And also it's gonna save you from multithreading problems and we're gonna see this actually later on why what that is So it's also modern So by that, I mean it's it has for instance like Unico support built in there's something like even Python didn't have properly in the second iteration And it has pretty good-looking syntax. It has great amazing tooling. In fact
We're gonna look at that a little bit later but basically you have a tool called cargo which is your package manager and it's also your build system and it's all that mesh into One thing and yeah that works out quite well, and then it's fast. It's really fast In fact, it's like see like fast because it compiles down to the same kind of machine code and it uses LLVM or the main
Rust implementation uses LLVM as its code generation back end so that you know You get all the benefits from that and then it's statically and strongly type So that means you know that if you have a type you're gonna stick to it And you can't have a like a dynamic type thing. So that also means that of course, we can't do funky things like
Your monkey pitching a type or monkey pitching a variable stuff like that These are things that you're gonna be that you have to be tricky about right but it works and you can't do it in Rust And then it's immutable by default now in Python. Everything is mutable by default, right? You can't like you have a variable you can choose to choose to change it like 20 times and it will just kind of
Work, this is a bit of a problem really like if you think about it Basically is most of your data, right? Heavy or most of your data read heavy if you think about it, it's probably read heavy, right? So it makes sense if most of your data was immutable by default, right and this will give you some guarantees And imagine that in Python you had a compiler which enforces this kind of behavior
And then you're actually gonna be have to be explicit about making things mutable if you want to change them and then basically just the Default is gonna be that it's immutable and actually the compiler is gonna warn you. In fact, it's gonna crash about that So it's also private body for that is and pythons. Everything is basically Importable from everywhere. I know there are some great tricks which you can do, but essentially
Everything is always public. So in Rust everything is always private Which means you're gonna be have to be explicit about which things you actually export which data structures You actually export which functions you export and this is quite cool because this way like you can't export too much, right?
It's it's always better. I believe to export too little and then to export too much Right, and then as I said, the tooling is amazing The community is amazing and I think probably the greatest point is that we have an amazing mascot. Look at that He's called Ferris and he is a really quite cute. And then of course you have a fearless concurrency. So watch out for that
So what does it look like? Right? And so here we have a Rust program quite a trivial one and Essentially what you have in the top there you declare a function using FN as opposed to pythons def and Then you put in an X and it's a string type ignore the ampersand for now basically as a reference
So so that we don't copy the string. We're very explicit about this and we have a Print LN thing also ignore the bang there It's a macro but just ignore it for now, but essentially you look as you see that looks kind of like the Python Equivalent which is like this right and you can see that's really quite similar, right? One thing to note is that you have the let names as opposed to just names
Basically you have to be explicit about declaring variables as opposed to changing them. So you have to have the let there Right, but everything else looks kind of the same right? The iteration looks kind of the same the the printing looks kind of the same So it's not really all that elegant to Python developers, right? There's obviously some funky syntax sometimes is that you can build right and also it's braced as opposed to
indentation syntax based which is nice because finally you can make you know, you can actually Format code and an idiomatic fashion that everybody can agree to that like, you know in Python you have people like new tab spaces Right stuff like that. So we I think we kind of agreed on four spaces, but there I know there's some companies
Which you know thing otherwise, but you know all right, so that's our you know, our base what we're gonna build off from and so rust empire now, I think Everybody's waiting for how to actually, you know, make rust and Python work together so as I said, we're gonna use py03 and It allows us to write Python modules and rust and
Allows us to use Python from rust, you know, so we can do it like both ways We can make it like a Python module like you would more normally make like a module in C and then import it in Python, but you can also have like the Interpreter acquire the you know, the Jill did global interpreter lock and then run the entire Python interpreter in rust Not sure why you would do that, but you can't do that. Right? So and let's make a Python module in rust. So
As a few things to note here, it's gonna be gonna look a bit funky at first but bear with me So let's just ignore the feature on top there And then the external crate is basically like this is this way you tell The the code the library to use an external so-called crate now a crate is like a package right the Python package
basically just this way you open a package right and it's on a package and then the use is basically like In Python would look like from something imports asterisk, right and this is essentially the same now
I know that we don't like SRS imports, but we're bear with me this it's a it's a talk, right? so and then you have this funky looking pie mod in it essentially just tells us what the Modules have is gonna look like right because in Python you have modules and in rust We also kind of do but you have to like make the bridge explicit I believe so. This is how that looks like and
Then you have a function you explicitly declare this function using this attribute on top. They are the pie of n And then we call it. Hello. This is gonna be the string that's gonna be put into the generated code and then conveniently it's also the same, you know, the the rust function name is the same as the the symbol that we actually export and
Then all we do is we just have like this we take in the name It's a string type and Then we just print the name and then we have those weirdly looking Okay, so which are basically just you know, empty empty results now We I'm not gonna tell you about rust and and error management. This would be a bit too much I believe but basically just say like let's just suppose that in rust. We always have to be explicit about whether we are
Returning an error or a result and in this case we are returning results. Alright, so Let's call this from Python. This is just what's gonna look like So, you know, like you're like you're on any normal Python module and you're gonna see that You know, this is gonna be the output and this actually works. You can actually take it like this There's no other boilerplate of this just works like that, right?
Of course, you're gonna have to have you like your cargo set up and this is not much right? This is just like basically like your default setup that you get if you have like cargo in it And then off you go. This is all you have to do. There's no see if I shit involved There's nothing else right? This just works like that So I think this is quite amazing and you can also see that we have some fancy unicode stuff in the code that also works
all right, so Let's build classes now Python is famously called a an object oriented language for good reason And that means we should probably be able to construct classes also from our rust code now The rust doesn't have classes, but the rust has drugs now Direct us a kind of like just data structures
which can have other data structures inside of them or other data types and So think of them like a Python class, but with some fewer bells and whistles now we can also bind methods to our structs and In fact, this is what we do here. We're using the impl statement that you see there
You basically tell it that case our starting from this point forward. We are implementing this class. So we are giving it functions, right? So you can see here with our Class or our struct has a list of strings like the back string is basic like list of strings It's just a vector and the vector maps to pythons list type
Vector is just the same has the same properties as the Python list. This essentially does that can grow dynamically it has One type in this case just because Python is dynamic obviously, we kind of have to bow to rust basically because we can't have like two different sets of
Things in there, right so And then we have a constructor now in Python the cost structure is called in it in this case we can't have in it just because basically at the time that we Constructed an object in there basically, because our rust code owns the while the rust code owns the pointers the
Python owns the memory so we kind of have to Walk around that by giving the like making a constructor is new and then instead of using any like Python uses in it This is kind of weird, but bear with me for a second but anyway But what we want to show is that we can make a struct that is gonna be translated to a Python class
that we can construct in Python and then it's gonna Have this dynamic list of strings in there, which is our num strings and we're just gonna give back the length of that Right. So let's do this in Python. This is just some a tiny little bit of boilerplate basically Because it can't know which class we're gonna add the module to Sorry, which much we're gonna add the class to and then yeah
This is our little struct there and then we can just import this Structs module that we have and then from that import the class that we've made Construct the class as you would in normal Python have the strings in there and then you know print the strings and it's gonna say That there's four strings in there. It's just fine. All right, so let's do something more interesting, right?
Let's calculate Pi but let's use a really bad way to do it And which is essentially think about it using like Monte Carlo, you know for me I basically imagine you have like a dart board, right? But we have only like one quarter of a dart board, right and you're throwing darts at it But you're extremely bad at it, right?
So you hit a random position every time you throw a dart, right? And basically what you do is in just like after you've thrown the darts you count like which ones are outside Which ones are inside and then using that you estimate Pi it's an extremely, you know Incorrect way to you know approximate Pi but it well, it will eventually converge to a correct thing, but
It's it's a very bad, but it does fit on the slide. So I chose to go with this So this is why we have this so in circle is essentially this method which checks whether the dart that you throw it is inside of this quarter of a circle or not, right and Then we have a function called calc which basically just runs a number of iterations and it throws many many darts in this case we throw a billion darts at it and in the end we just calculate Pi using like four times the hits
divided by the number of iterations and as a float and this way this way we get Pi and We just let us run this and we're gonna end up with a really better approximate Like this is one billion runs of this rather than we have like three point one four one six, right?
This doesn't quite work. Don't do this. Please ever at home and we but we take four minutes and ten seconds to do this All right, this is quite bad. Right? We need to go faster Right, let's let's make it faster so we use some rust to code to do this and Essentially, this is a more or less direct translation of that There's one new construct which we have here, which is this one dot dot iteration thing that we have
Basically, this is a range like in Python. You have ranges using like range one comma like iterations This is essentially the same thing but using rust syntax and then on every iteration we map like Same as in Python and as we don't care about the value like the way would be like one two three Like we don't care about that. We just want to do something for every iteration that we have
Right, we could do this in a less procedure a little less functional way But there's a good reason we do this and we're gonna see this in just a little bit but anyway so we call our random generator for every one of these iterations that we have and it's either gonna be a one if it's in the circle or it's a zero if it's not gonna Be and then the end we use the sum
In order to sum up all of our hits and then just the same we just do the same calculation essentially as we did in Python and this way we're gonna get pi and This is what the binding looks like. It's essentially exactly the same that we had before and we're just gonna run this like import this run it and
We go we're down to five seconds, right? But I'm still not feeling it. We need to go even faster right, so What we're gonna do is we're gonna paralyze this and we're gonna use a library called rayon Now rayon is a thing that essentially gives you iterators, but it parallelizes them
So ras does many things with iterators because iterators are fairly safe, right? They know their ranges They they can check themselves. So it's pretty cool So if you look at this code will notice that there's very few changes In fact, there's only two lines which have changed which is this into par iter so a parallel iterator, which is a thing provided by rayon and
Then instead of map we have map with now map with it's required Because you can see that there's this RNG maker, right? We have to be careful We have to be mindful of our RNG or random number generator because we obviously don't want every threat to share the same Random number generator state right? We need they need to have different states so I have this RNG maker which is like which would just import and essentially just make sure that we have a
Very fast but also well seated our RNG at our disposal, right? so and this is exactly the same code just as the as the kind of module code and So we want to run this and we can see we're down to 1.7 second, which is pretty good
now This rayon thing spawned like a threats for us because my left over has a course but it will automatically choose the right amount of threats for your machine and it will also Do this in a very efficient manner so it will prefetch tasks
it will figure out how many tasks there are and it's gonna build its own workers stealing queues and it's just gonna implement this by Itself and it's pretty cool and we have to do very little and in fact, this is entirely safe code So like there's no way what we could have data races there, right? There's no way that we could mess this up, which is pretty amazing I think we did very little work there to speed up our rest program and it's basically completely parallel now
How do we get even faster from there? There's probably a few ways like it would probably help if you didn't use a completely stupid Algorithm to approximate pie this would be a start, right? But you know more realistically if we went down this road and absolutely wanted to use this algorithm You could probably use some SIMD. So like single instruction multiple data You've probably heard about SSE instructions from Intel or MMX or AVX2
Which are some instructions you can use to speed this up even more and it's quite easy Otherwise, you can also use iterators as a library which is exposes iterators and it allows you to work on like 32 floats in parallel Which is pretty great And then of course you can do cache optimizations
Which you know probably you should do this in this order because you know cache optimizations are kind of gnarly to get right Let's look at some graphs how we actually did. Oh, just okay So you can see that C Python didn't do so Well, I did just try out Cython just you know for shits and giggles essentially and I'm not the Cython expert
I probably did something wrong. I think it's probably the slow Python RNG is what I'm thinking So let's ignore this for now. Piper did quite a bit better at 50 46 seconds and we can see that Erasmus single-threaded and multi-threaded You know far exceed that Thankfully, right because otherwise we would be feeling pretty stupid at this point
Right and we can also do it the other way around right if if we're feeling that our pulse and Python is just a bit too fast, right we can use Our rest is a bit too fast. We can use Python to slow down the rest quite a bit, which is essentially we do By you know acquiring the Jill right because obviously we have like Python like Russ can't cheat, right? Even if it's Python like even if it's Russ Russ can't cheat
So we have to acquire the Jill which is essentially like a mutex in this way So only one thing can operate on the Jill mutably and then we import Python and then we just kind of import like using the Python interpreter import sys and then we can just get the version from then you can see that it actually prints this just fine and
This is actually you know, this actually run on my system and this is what it prints But you know, why would you do this to be honest? I have no idea but you can do it if you ever like maybe there's actually a reason right? Maybe if you want to import like even if you want to use some kind of odd kind of Python library in your Rust code, I don't know but you know, there you go. All right, so takeaways, right?
Rust can make you Python quite fast and the pyro3 integration is Really quite easy. I believe right? it's it's quite a joy to work with this and Would you would I use it in production probably no, I gotta be honest there for no particular reason just that it's you know
Quite young of a project. I believe it's got a great direction Full disclaimer. I'm not involved in this in any way so I'm just I just wanted to show you guys what this looks like and That you can combine Rust and Python with a very low overhead very low boilerplate kind of fashion Yeah, but apart from that. Thank you for your attention
Close to it because Hello Does see it does cargo generate Python files when you compile these rust code or how do I? Tell Python that there is actually a compiled rust module that I can use some Python or is there something that I have to add to a setup.py I don't quite get it to be honest. So if you if you compile the rust code right with cargo you get some
Binaries. Yes, you get an SO like you would get if you compile to see extension module for instance Python can directly import those. Yeah, but you have to edit to set up high so that it gets a package with you. Yes Yes, you do. Thank you
Hi, thanks for the talk Does py03 give any kind of direct interoperability with numpy and its formative arrays? No, I don't believe so, but you could add traits to do this and you can't do your own kind of exchange
Functionality during in the like where you had this pie of anything you can Clear there and probably find an efficient way to do this if in case that pie it suppose numpy exposes C aligned array and if you have that you can very efficiently do that Thank you
Absolutely like Sorry, no Right, there we go. Yes Right
Sorry, I was trying to figure out how Python you the sys module had a dot get method, but it does but that's not This module that's
No worries, I'll ask one one question is maybe it's it's I mean, what would you recommend us like a path for learning or us? Like what resources have you found useful in learning or us? Oh and learning rust
To be honest the there's this rust book. It just called that rust book actually version 2.2 point 2.0 Yes, and it's really quite good. It's Team and To be honest this way you run you learn a lot of rust
There's also the rust cookbook and also rust by example Which are all great resources and you can actually just kind of click the code and it will compile On some server and run in your browser and this is a quite nice way to explore that but you can also Quite easily like it just install it on and basically every system it will work
No, you don't you like you can use in extrinsics, but we don't do that. So as I said like if you have a look at this syntax Here where you have basically into par itter, right? This will give you a parallel iteration
overall like that will just kind of do the parallelization for you and there's a library called faster and You know It will do the same thing But using some instructions, so essentially you don't see you don't even see that it's it's some base backend It will just do this for you. In fact, we could have combined that but to be honest
I thought it would get quite confusing right because you have to parallelization things going on but basically you have three labels you have the the architecture based Intrinsics, which you can use directly if you're feeling like that, right? But then you can have also the standard standard si MD which is just a tiny bit above that Which kind of abstracts everything away from you and then you have crates which again bit on top of that and give you very nice
abstractions on top of that which will also do like one time runtime detection and they have like ways to kind of you know fall back from a VX to to a VX if you don't have that hardware, so It depends on how you want to do this, but they're like everything is there
Right. Is there a way to automate the generation for deployment? I mean going live and Linux system or you are working in your Mac OS environment You need to compile by yourself, but you can somehow Automate it in your setup in the PI
the you mean compiling of the rust instead of Including in the bundle all the cell files. How do you will go to production with rust plus Python code? Well, yes, I mean what what you can use looks like for instance You could use that in order to easily package that but to be honest
I just have my setup PI and it will put the binary into there and it will just work Okay, so you are there at the binary I mean if there is a way to automatically compile in the moment that you first run the server All right So what I see so you want to basically compile the rust code without pre compiling that so you want kind of you want to kind
Of compile in production. Yeah I mean I Mean, I suppose you could do that. There's nothing stopping you from that I would not recommend that because of the you know performance characteristic of that might be a bit you know hazy, especially if you have a lot of rust code to compile and especially because like the the cargo instruction or the cargo build might download some other crates which might be a
Security problem, right or you might have like proxy issues So I would certainly not recommend that but there's nothing stopping you from like having a rust binary which does that okay? It's about the bundle generation everything. Yeah. Yeah. Yeah, I would certainly pre generate that for production at least. Thank you, right