HNHacker News
TopNewBestAskShowJobs

miguelgrinberg

621 karma · joined December 2, 2013

submissionscomments
miguelgrinberg··on Microdot: Yet another Python web framework
The main thing that none of the frameworks you know offer is being small enough to also work under MicroPython on $5 microcontrollers. I created Microdot a few years ago when I wanted to have a web interface to configure a thermostat that I built to control the heating in my house.
miguelgrinberg··on Microdot: Yet another Python web framework
Microdot creator here. Happy to answer any questions about Microdot if you have any!
miguelgrinberg··on We Have to Talk About Flask
My assertion is that none of the refactorings in the 3.0 release bring a benefit to the community. I did not imply that the entire 3.0 release is void of improvements.
miguelgrinberg··on We Have to Talk About Flask
Explain to me how you would apply this concept to a book. Or to a YouTube video.

I'm not unreasonable, I get that things have to change from time to time. I just think maintainers should think more carefully when they introduce breaking changes. The cost to them is very high!

miguelgrinberg··on We Have to Talk About Flask
So consider what happens when you try to learn Flask in a world like the one you describe. You pip install Flask, and you get 3.0. Next chapter asks you to install Flask-Login, and now you are forced to downgrade Flask.

What you are saying makes sense when there are important reasons to break compatiblity. But I expect the Flask side to love their users a bit more and not break their code for trivial reasons.

miguelgrinberg··on We Have to Talk About Flask
Normally tutorials ask readers to install latest versions of everything. If you have to provide a version for every package used in a tutorial, it means that every time any of such dependencies releases a new version the tutorial has to be updated. I guess it is possible for a blog post, but how can I update my books or my videos?
miguelgrinberg··on A toy programming language in 137 lines of Python code
Knowing how to build a parser manually will make you much much better at generating, and most importantly debugging, automatically generated parsers.
miguelgrinberg··on Goodbye, Twilio
Have you reported these? The library has a fairly complete testing suite, and if you are saying there are regressions I'd like to know what those are so that I can make sure the testing is adjusted to cover those cases going forward. Thanks.
miguelgrinberg··on Goodbye, Twilio
Thank you so much. Glad to hear you've found my work useful.
miguelgrinberg··on Goodbye, Twilio
Thank you, Ricky! The privilege was also mine. :)
miguelgrinberg··on You don't have to engage with people on the Internet
What few people understand is that by responding you are also elevating the engagement score of the ridiculous take and ensuring it gets in front of many more eyes.
miguelgrinberg··on SQLite or PostgreSQL? It's Complicated
I explain this in the post. The goal is to optimize the application for users. I really don't care if Postgres is faster than SQLite or viceversa, I just want users to have a snappier application. The experiment was to swap out the database while leaving everything else the same to see if that affects the overall user experience in a positive or negative way.

Also note that I'm not saying Postgres is faster the SQLite in absolute terms. That happened to be the case for this particular application and how it was deployed. If you perform a similar test with a different app or stack you will likely get different results. A main point I'm trying to make in the article is that people should do their own benchmarking instead of making decisions on stuff you read online.

miguelgrinberg··on SQLite or PostgreSQL? It's Complicated
SQLite isn't running in WAL mode. This application isn't just read-heavy, it is ready-only for users, so I wouldn't think this will make a difference. The writes occur while everybody is sleeping, from a cron job that runs once a day to upload the traffic for the previous 24 hs.
miguelgrinberg··on SQLite or PostgreSQL? It's Complicated
This isn't the topic of the article so I haven't included it, but I have taken several "solid steps" to optimize this application throughout its year and a half of being in production.

This article is about one of them only, how I designed a test system to evaluate the two databases head to head.

miguelgrinberg··on SQLite or PostgreSQL? It's Complicated
I did not feel that was a relevant topic for this article. I have spent a good amount of time over the life of this application optimizing indexes, though. But the article is about how I designed a test to benchmark these two databases, not a general discussion on all the optimizations you can make.
miguelgrinberg··on SQLite or PostgreSQL? It's Complicated
For this particular application I discuss in the article it would make no difference, since there is only one not heavily used table that uses UUIDs. All the other tables use integer primary keys.

Also this may be not a very popular opinion, but I prefer to design the database without using database-specific features. Things such as using SQLAlchemy and sticking to basic types. Sure it may affect performance some, but thanks to having done that I was able to port the app from SQLite to PostgreSQL in like an hour.

miguelgrinberg··on SQLite or PostgreSQL? It's Complicated
The point of this exercise was to determine how these database perform with same schema, and if it makes sense to make the jump from SQLite to PostgreSQL or not. As a side note and since you ask, the indexes on this database are fairly well thought out, I have exhausted all ideas on indexing improvements to help with performance. I do mention a major implementation enhancement which is to precalculate monthly totals.

Also, another important point I tried to make is that this benchmark is useful for this particular deployment. I don't really want to convince you the numbers that I've got will also apply to you, my proposal is that you should test your application and make decisions based on your own results, which can certainly be different than mine.

miguelgrinberg··on SQLite or PostgreSQL? It's Complicated
This is 100% correct. This is a dashboard application that is mostly read-only for users. There is a cron job that imports and writes new data once per day.
miguelgrinberg··on Flask Mega-Tutorial (2017)
I think you are oversimplifying this. If you don't know how FastAPI handles sync code, then you can't claim it is on par with Flask. I suggested it might use an executor, after looking in their code, they use a thread pool support in Starlette, which in turns imports this thread pool logic from AnyIO. I see no easy way to determine what is the size of the pool. Clearly this isn't designed as a main way to run code, it is just a quick way to run sync code w/o blocking the loop. I would not consider this up to par with the concurrency you get from Gunicorn or uWSGI using a configurable thread or process pool.
miguelgrinberg··on Flask Mega-Tutorial (2017)
Not sure what you mean by "ignoring async". If you write your handlers as regular functions, I would imagine FastAPI is going to send them to run in an executor. So all the concurrency benefits of FastAPI go down the drain, and now your concurrency is based on threads.

As far as Swagger integration, you can use APIFairy with Flask and get similar type of auto-generated docs. Disclaimer, APIFairy is an extension that I created: https://github.com/miguelgrinberg/APIFairy

miguelgrinberg··on Flask Mega-Tutorial (2017)
Something that I think not everybody realizes is that Flask does not require extensions for most things. The extensions are nice because they integrate with the Flask configuration object, and with before/after request handlers when it makes sense, but none of that is required. If an extension stops being maintained, you can always find a newer general purpose Python package that does what you need and just use it in your Flask app.

Now this is my personal opinion, but you cannot say the same about FastAPI. Even though the ecosystem of asyncio compatible libraries has grown, it is still several orders of magnitude smaller than what is available for standard non-async Python. So in my view, in terms of access to 3rd party libraries Flask is a better choice.

miguelgrinberg··on Flask Mega-Tutorial (2017)
This is really a matter of preference. I do not use Flask-Admin on my projects, I have always preferred to design my own admin pages than being forced to accept the choices that are imposed by these big extensions. This allows me to have a consistent UI across admin and non-admin pages.

One thing that people often complain is that it is hard and/or tedious to build tables with data, which is one of the building blocks most admin pages need. Last year I wrote a blog article where I show how I build tables in my Flask apps: https://blog.miguelgrinberg.com/post/beautiful-interactive-t....

miguelgrinberg··on Flask Mega-Tutorial (2017)
Flask Mega-Tutorial author here. This was a surprise. :)

Happy to see people continue to find my tutorial useful and relevant. If you have any questions, I'll be happy to answer.

miguelgrinberg··on Sync vs. Async Python: What Is the Difference?
Hi, author here.

I believe I did discuss this, and in fact, I list the same a) and b) conditions you mention using slightly different words. Quoting the article: "To benefit from the async style, an application needs to have tasks that are often blocked by I/O and don't have too much CPU work."

So I think we agree.

miguelgrinberg··on Build a WhatsApp Chatbot with Python, Flask and Twilio
Yes, this is true. I will be involved with the Twilio blog as part of my duties, by writing original articles and also by working with other contributors to get their posts published.
← PreviousPage 2 of 2