What's So Special About this Python Framework?!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
we are certainly spoiled for Choice when it comes to web Frameworks with python and even if you look outside of the top big four I suppose there are plenty of options there for you to use to build your applications and apis so why am I interested in this one and why am I talking about it well there are two main reasons the first is that it is written in Rust now that comes with the benefits of other low-level languages that gives us that performance boost that python can be lacking in certain areas but the second point is the one that's the most interesting to me and that's the fact that there seems to be a growing Trend in building python libraries with rust I think this is to do with the booming popularity of rust and the fact that people enjoy writing with or I can see the benefits and in fact there's an up-and-coming data science Library called polars which is showing to be gaining popularity and has that performance advantage over something like pandas now overthrowing pandas in that space is probably quite an undertaking but I think that may makes it even more interesting don't we already have this though with C libraries well yes we do in fact my favorite HTML passer a selectolax is built on top of modest which is a C library and in fact you can see how much faster it is already with that so what we're going to do today is I'm going to have a quick look through the repo and then we're going to write a short app or an API and then we'll performance test it at the end just to see where we are at so let's get started so this is the website here and we can see that this looks fairly standard fairly straightforward if you've written any kind of application in Python this will look pretty handy and pretty normal to you we scroll down we have some cool important keywords like async support simple API and of course blazingly fast which I think just comes part and parcel with rust these days also sponsored by digitalocean which is pretty cool so let's have a look at the actual source and if you go where is it down here you can see that this is 45 rust this repo and we look under the source code here we've got all of this cool stuff here here's the server code all written in Rust now as I said in the intro that's quite interesting and I hope things like this gain more popularity so more people are interested in expanding the python and rust relationship just so we have loads more cool options of things to work with so what I've done here is I've got a server running already I copied out the basic example and you can see it's running here and I'll go back over here and we have this response here pretty cool neat and all straightforward so let's go to the documentation and this is where you're going to find one of the pitfalls on the downfalls of a new framework that is possibly maintained just by one person is the fact that a lot of the documentation is missing but if you like this sort of thing and you like this framework there is absolutely no reason why you couldn't contribute to some of this too so what I want to do is I want to build a real simple uh API which we're going to give it some parameters and it's going to return that data in its response and then we're going to throw thousands and thousands of requests at it and see what happens so let's have a look for that so we want to be under um features Maybe and I'm looking for here we go Dynamic routes so we'll do that's a post one but that should be fine we can specify it like this and then we can just return Json if I we might need to import that in okay so that's cool let's do that then I'm going to shut this server down Okay so let's change this to giving it a number I think we did it like this let's give it an ID and then we wanted to put in I believe the request param so it was or am I looking uh request params ID okay so let's just say our data is equal to request params and then ID like this so we should now be able to return out this I think if we go back here let's just remove this stuff and we will return out uh Json fi which we might need to import yes we have and create a dictionary and we'll just say data is going to be equal to the data be sent in right let's run that python main.pi server's running let's see if we give it something we get it back we do indeed so there we are whatever we put in here uh it could be anything I think uh something like this maybe we get it back like that great so this server is now running so what I'm going to do is I'm going to leave this running I'm going to start up a new terminal make this a bit bigger so you guys can see we're going to be using a tool called hey now hey is basically going to spam this with requests to the IP address that we give it and I think ours is 5000 and let's just put in this so in case you didn't realize I'm going to turn it down from 200 000 and we'll make it 10 000 to start with and let's see what we get back so we got our results uh and we'll find you see 99 what happened in 0.006 seconds which is pretty quick now obviously this is just subjective this is over the local network and let's be honest the thing that's going to slow you down when you're doing stuff like this is your i o your input output basically your database so this is all subjective what I'm going to do now is I'm going to close this out and we'll actually go and get a fast API one up okay so that's on 8 000 and hopefully this does the same thing yes it does okay so I'm going to move this let's make this a bit smaller so we can see that let's create a new terminal underneath and we'll run hey again on Port 8000 you can see all the requests coming through on my fast API and here's the response the results so look at the difference in the histograms again this is this test is totally subjective and doesn't mean a whole lot but if you look the fact that these ones were 99 up right here and this one is a bit further lower down distribution was 99 in 0.02 seconds 19 90 in 0.006 so this has got potential I think now I know this is all subjective but I do find it quite interesting that these sort of options are becoming available to us and I think it's good and we should show support to people like the creator of this framework so they can continue to grow and give us that extra option for when we're building Niche or a niche apis or web or web apps within python if you've enjoyed this video I think you're going to enjoy this one here too where we talk about more API stuff in Python
Info
Channel: John Watson Rooney
Views: 10,480
Rating: undefined out of 5
Keywords:
Id: _b7Ni92TyOw
Channel Id: undefined
Length: 6min 55sec (415 seconds)
Published: Mon Jan 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.