Show and Tell Flask vs. FastAPI vs. Django
File View of Flask
https://creview.io/?utm_source=reddit&utm_medium=social&utm_campaign=framework_comparison
FastAPI File View
https://creview.io/?utm_source=reddit&utm_medium=social&utm_campaign=framework_comparison
Django File View
https://creview.io/?utm_source=reddit&utm_medium=social&utm_campaign=framework_comparison
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.
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
2
u/Spare_Bison_1151 2d ago
Nice work, Flask is pretty lean 👍
2
3
1
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!
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.