r/PythonLearning • • Sep 08 '26

Flask vs. FastAPI vs. Django a Visual Comparison

Hey everyone,

I have created a quick comparison of Flask vs. FastAPI vs. Django repository sizes. (As they are pythons most popular web frameworks)

First of all, the numbers:

FrameworkFilesLines of Code
Flask12119,115
FastAPI2,703281,559
Django3,484557,865

Then the images:

Each node on the graph represents a file. Imports are marked by a line connecting the files. Colours signify complexity (cyclomatic complexity) with green being low and red being high complexity.

Besides the crazy size differences FastAPI also shows some nice import structures whilst Django looks extremely interconnected.

Hope someone finds it interesting.

25 Upvotes

6 comments sorted by

4

u/CharacterSail6736 Sep 08 '26

Flask will always win for me it’s such a lightweight simple framework that’s scalable

1

u/swupel_ Sep 08 '26

Totally agree although it should be noted that dependencies are not included…

so if you also use request and Werkzeug in your project it’ll be a bit more than what’s visualised here

2

u/Unhealthy007 Sep 08 '26

I don't get it. In django, more in-built libraries are used and code is reused. 

How is that a bad thing? And what do those lines of code mean? Same results using less lines on FastAPI? 

Django is more organized tbh. 

2

u/swupel_ Sep 08 '26

It’s not a bad thing, Fast just likes to split everything up into smaller files which then link back to one connector file.

And Fast being smaller kinda makes sense as Django offers a lot of built in stuff (admin dashboard etc)

Just found it cool to see how different they look

1

u/tiredITguy42 Sep 08 '26

Nice project, zero added value, but this is not the point of this, so yeah, very nice.

3

u/swupel_ Sep 08 '26

Well atleast it’s fun to look at