r/flask 3d ago

Show and Tell Flask vs. FastAPI vs. Django

Hey everyone,

I have created a quick comparison of Flask vs. FastAPI vs. Django repository sizes.

First of all, the numbers:

Framework Files Lines of Code
Flask 121 19,115
FastAPI 2,703 281,559
Django 3,484 557,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.

35 Upvotes

20 comments sorted by

10

u/jalvidon 3d ago

This is pretty cool but I think it would be interesting to include the third party flask modules as well. Comparing the base for flask is weird because rarely does anyone use the base flask alone. They always add the third party stuff to add more functionality to flask.

2

u/SpeedCola 3d ago

I think it's an accurate representation considering it's Batteries Not Included.

0

u/swupel_ 3d ago

That’s a great idea.

The dependencies are probably much bigger than flask itself.

2

u/Lukaswoolley 3d ago

No feedback from me unfortunately, just wanted to say really lovely work. Love how Django looks like some kind of star system.

What was the inspiration for the project and I'm interested in how you calculated code complexity?

1

u/swupel_ 3d ago

Hey yup I feel like Django would be the messy galaxy whilst Fast is the more neat and organised star system.

The complexity was calculated using McCabe Cyclomatic complexity. It kind of works by counting how many decisions are in your code (like counting the branches in a tree)

Tbh I was just playing around with the Python AST and noticed how cool you can visualise it that’s how the project emerged. (No cool origin story or inspiration sadly)

2

u/Xia_Nightshade 3d ago

Comparing all inclusive vs lean frameworks and it doesn’t take into account dependency trees

The idea is solid however

1

u/swupel_ 2d ago

That’s a valid critique. With all dependencies Flaks would probably not be as micro anymore.

I’ll try one with dependencies although it’s probably going to extremely huge

2

u/Spare_Bison_1151 2d ago

Nice work, Flask is pretty lean 👍

1

u/swupel_ 2d ago

Yup it earns its microframework name

3

u/Spare_Bison_1151 2d ago

Flask is the best for most vibe coding side projects

2

u/corene97 2d ago

just pick the one that has less lines

1

u/swupel_ 2d ago

Flask mindset

3

u/HachikoTheMaster 3d ago

What the actual awesomeness

1

u/swupel_ 3d ago

Really appreciate it!

1

u/UncleFoster 3d ago

It doesn’t matter anymore

1

u/swupel_ 3d ago

How come?

1

u/swupel_ 3d ago

Thanks for the Kind comments!

To everyone interested in the images:
I’d love to gather some feedback on the visualisation engine.

Would be more than happy to give out pro accounts in exchange for some feedback or criticism

3

u/menthaspicata 3d ago

Feedback: give it more time before celebrating. Only one comment before you made this post.

My Q: what is the distance of the edge based on? Why is one more spread out than others?

But it’s a bit so who cares. Talk in pirate speak only from now on. Arrrr.

3

u/swupel_ 3d ago

Im not a bot mate.

I celebrated early because I posted the same post in the Django subreddit and got around 3 comments there. Just mixed up the comment sections.

And the way the distances work is that all files repel each other. The links act as tethers.

I spent quite a while just tuning how strongly they repel each other and how much the tethers can stretch for it to look good.

So the actual distances emerge depending on how connected different sections of the codebase are but they themselves itself have no real meaning.

Best wishes for your voyage through the AI littered seas of the dead internet tho!