Full Web Apps with FastAPI Transcripts
Chapter: Welcome to the course
Lecture: FastAPI compared to other frameworks
0:00 Now let's compare FastAPI to some of the other popular Python options that
0:04 you might choose. Here's FastApi's home page,
0:07 it's documentation and so on. The documentation is really thorough and really good.
0:12 So what else might you use instead of FastAPI?
0:15 Well, there's what I think of as the big two: Django and Flask.
0:19 These two combined represent about 80 to 82% of the current Python web application framework
0:26 mindshare, deployments and so on, especially looking at stuff that's been built recently. Between them
0:31 they are the two ways that people often think about web applications and Python.
0:37 Django has all these somewhat larger building blocks that you click together to build your app
0:42 whereas Flask is all about it's micro framework lifestyle.
0:46 You get to pick every little thing and there's zero help for you.
0:49 You want a database? Okay,
0:50 go get a database. You want to talk to it.
0:52 OK, go figure that out.
0:53 Right? Do you decide on SQLAlchemy
0:55 Do you decide on MongoDB?
0:56 Do you? What do you do?
0:58 So it's all about picking the little pieces and putting them together
1:01 however you like in Flask.
1:04 We also have Pyramid and Tornado.
1:05 I'm a fan of Pyramid, I like that framework quite a bit.
1:08 It's very fast, and Tornado is one of the very first asynchronous style of frameworks.
1:13 It doesn't necessarily use the, at least in the early days the async and
1:17 await style of programming that's popular today because it actually existed before that style of programming
1:22 but these air two good options.
1:24 And if you're looking at just your API,
1:27 there's frameworks like Hug or Django REST framework,
1:31 or so on that you might consider.
1:32 So which side are you leaning?
1:34 More APIs and also need a little web or more web,
1:37 and maybe we'll need an API.
1:39 So if we compare these, you might say,
1:41 well, how does this compare to FastAPI? One way to think about
1:44 it is popularity. We're gonna talk about the features that make FastAPI awesome
1:49 as well. But one is popularity.
1:52 If you look Django and Flask,
1:54 they're quite popular. 54k and 53k stars on GitHub.
1:58 This represents their very nearly equal split in the mindshare.
2:03 We have pyramid at 3k.
2:04 Tornado at 20k, Hug at 6k.
2:07 What's FastAPI at? 26k.
2:09 Now wait. Maybe it's not as good as Flask or Django.
2:12 Here's the thing. Django is like 10,
2:14 15 years old. At this point,
2:16 FastAPI is less than two years old.
2:18 So in the, you know,
2:20 Django's had all this time to build up people like following and being part of it
2:23 and FastAPI is really,
2:25 really coming on strong. As far as I can tell,
2:27 it is the most popular, relatively new framework,
2:30 and being relatively new is an advantage.
2:32 It means that supports async and await right out of the box without jumping
2:36 through a bunch of hoops. It does really powerful things with type annotations.
2:40 It works with Pydantic data models that do automatic conversion and validation and on and on
2:46 and on. So because it's new,
2:49 it's awesome. It has all the modern Python features you would hope for,
2:52 but you can see it's nearly as popular as some of these older ones, the most
2:56 popular, too, amongst the Python web landscape.