Live data from Hacker News

Flask 1.0 Released

palletsprojects.com

141–150 of 184 posts

Re: Flask 1.0 Released

#141

Earlier quoted context omitted.

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.

Re: Flask 1.0 Released

#142

I understand that Flask has become popular because it is easy to learn, but my experience is that as your knowledge progresses it just keeps getting in your way. I particularly dislike some design choices which look like afterthought hacks, such as global variables for current request and using abort() functions instead of raising exceptions directly. EDIT: To avoid hollow naysaying, here are some alternatives to Fla…

I've always preferred CherryPy[0]. It's simple and if you write simple Object Oriented code (or have written some) you can turn it into a website, just need to "return" URLs. CherryPy has also been around 10+ years by this point (longer than Flask it seems). I like that I can stay high level, and when needed get really low level with CherrPy.

I've used Flask in one other instance, and it wasn't too bad, but I missed CherryPy through the process (cleaner looking code, and obviously more familiarity for me) but I was participating at a Hackathon so maybe my experience is a little shifted. Though I never picked Flask due to never liking how it looked from even just the Hello World I was not a fan of how it's written, but that is just me coming from other languages and looking at frameworks like Sinatra (though I don't do any Ruby it was pretty clean) and Nancy (C#).

[0] https://cherrypy.org/

Re: Flask 1.0 Released

#143
Flash was the first backend framework I really understood. It was very easy to get started with. I no longer use it but it made it so easy to learn web development.

Re: Flask 1.0 Released

#144
post #67

Earlier quoted context omitted.

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

Re: Flask 1.0 Released

#145

Earlier quoted context omitted.

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,

use psycopg2cffi: https://pypi.org/project/psycopg2cffi/

Re: Flask 1.0 Released

#146
post #17

I understand that Flask has become popular because it is easy to learn, but my experience is that as your knowledge progresses it just keeps getting in your way. I particularly dislike some design choices which look like afterthought hacks, such as global variables for current request and using abort() functions instead of raising exceptions directly. EDIT: To avoid hollow naysaying, here are some alternatives to Fla…

>global variables for current request Not really global variables. I would analogize it to dynamic variables from Lisp, which are a feature I wish every language had. I strongly disagree it's a hack or gets in the way. Having access to the request from anywhere without explicitly passing it around is really useful.

The context local request object is nice (once you accept it), but it definitely complicates the testing story. Whether that is a worthwhile trade-off depends on how many tests you write I suppose.

Re: Flask 1.0 Released

#147
post #13

Earlier quoted context omitted.

The real value of Flask is that it makes you appreciate what Django does by default. When I first started learning Python / web frameworks, I went with Flask because it was smaller and "simpler". As my project grew however, I had to organize it. I was basically imitating what Django gives you by default, though less cleanly.

Both Django and Flask make me yearn for Rails :(

i learned to program with python and flask and promptly started hammering out my project. flask was great for learning piece by piece what goes into a web app but eventually it grew to a point where i was relying on all these extensions that were no longer maintained and i was spending alot of time to configure and setup every last bit of functionality i needed and every extension was like a new DSL to learn.

The obvious move at the time was to move to django and I spent some time familiarizing myself with it's own DSL. But boy was i struggling all along the way to do things how I liked in Flask with django. The Django Templates were extremely limiting (no modules) and couldn't even do regular python things and I came to find that extensions for Django were in no better shape than flask's. There was no clear solution for rate limiting and various other things I was looking for.

I've followed rails from a distance for a long time but, coming from python, ruby seemed so abstract to me i could just never figure it out but towards the end of my django time, i was finding that rails did/had everything i wanted and it all worked just the way i wanted it to and it was calling to me really hard. i took a big leap and spent a couple months diving fully into ruby, doing all the tutorials, reading all the books. at this point i am officially converted and my project app with it is already further along than i ever got with flask or django. when they say "ruby/rails is built for programmer happiness", they really mean it. and i can really feel/appreciate it. it's extremely fun to use and to see real progress without having to rack my brain and figure out some internals before i can proceed every so many hours. i'm just getting shit done and things work just how you'd intuitively think they should. rails ftw

Re: Flask 1.0 Released

#148

Flask is an interesting project. Created by a true Python master only to be nearly abandoned, and yet it remained so popular it was later revived by a new group without a major fork. How often does THAT happen? The post describes it as "stable for a long time" :)

Flask does what it was intended to do. To add more stuff to it would defeat the purpose, and turn it from a micro-framework into a regular framework.

If a micro-framework adds a "web forms abstraction", honestly, run the other way.

Re: Flask 1.0 Released

#149
post #48

Earlier quoted context omitted.

In my experience, Django is less suitable for large projects than Flask. The nature of Django encourages tight coupling between unrelated parts of the system - Models intertwine database operations and business logic, ModelViews intertwine db operations, business logic and the interface layer. This is manageable in the small, but when you hit scale, this tight coupling adds a whole bunch of unnecessary complexity to…

Django is great for building Django apps. That is, if you're starting a greenfield project and don't have to integration with an existing database schema, and you like the Django ORM, and you like Django templates, and your data model maps cleanly onto a relational DB, and you can use the admin site more or less as-is without having to customize much, then it's lovely! I'm not being sarcastic: it really is. We've suc…

> Every time I've needed to deviate from the Django Way of doing things, it's felt like I'm swimming upstream against a rapids.

I agree -- if you use Django, you have to do it the Django way. Flask is more flexible.

Re: Flask 1.0 Released

#150

Earlier quoted context omitted.

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.

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.
Post reply on HN