Hacker News new | past | comments | ask | show | jobs | submit login

Flask _does_ scale really well with lines of codes. However the limitations of Python w.r.t. async log really start to show once you step beyond simple CRUD apps.



This was my experience. Just exited a startup that relied on Python heavily. Built a flask-restful based back end with SQL Alchemy.. Never had any issues with flask per say, but it made me happy I know languages with far better tooling and concurrency experience/performance :)


Did you ever attempt to use PyPy? Flask works with it, and in my experience the handful of times I've needed Python to be more performant, PyPy got me there easily.

My use-case was I was doing a heavy part of an ETL pipeline out of MySQL and it was taking an unreasonable amount of time. PyPy was a roughly ~8x speedup, which ended up being faster than doing direct manipulation with MySQL via the cli (!!!).


For interest sake, can SQLAlchemy run on PyPy; pgsql driver support? thanks,


I haven't used it in production (only made some benchmarks), but the recommended approach is to use the pg8000 driver (https://github.com/mfenniak/pg8000) with pypy, instead of psycopg.



SQLAlchemy can run on PyPy, but you have to use pg8000 (pure Python) or psycopg2cffi (cffi port) instead of psycopg2 for pg.


Just use sanic. It's a mostly drop in replacement for flask that is async first and runs on uvloop.


The unfortunate bit is you lose out on so much of the ecosystem going hard on asyncio right now though (like sqlalchemy orm).


aiohttp + pee wee async is the best combination available right now IMO. A fully asyncio app with pleasant non-blocking ORM and migrations.


I'll have to give that a shot sometime. :) Haven't used peewee before, as sqlalchemy has mostly been tremendous.

That said, if I'm starting a new project where I'm pretty sure I need async io, I'm not sure Python is my first choice. It's got decent facilities but compared to other ecosystems it's not as mature there


Quart is another option. Even more of a "drop-in replacement" than sanic.


Can you elaborate a little more on `limitations of Python w.r.t. async log`? I have switched to Django + Gunicorn which seems to be handling requests just fine.


I meant async logic. So that means things like worker threads and messaging. It's more of a limitation of Python as a language than anything else. As bad as NodeJS is, the fact that it's underpinned by an event loop makes it more powerful with async stuff. Golang is better, though a little funkier.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: