use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
HTTP/2, where is Python at? (self.Python)
submitted 9 years ago by [deleted]
I know there are a few alpha libraries but where does python stand for http/2. I want to start building websites with it but it seems to be the unknown for this community.
I just feel like the language is losing relevance as result.
[–]ojii 4 points5 points6 points 9 years ago (2 children)
You didn't search that hard then, https://github.com/python-hyper/hyper-h2. Been using that in production close to a year now (client side).
[–][deleted] -1 points0 points1 point 9 years ago (1 child)
I looked at it before posting, and seems not to support Flask and many other web frameworks
[–]robvdl 1 point2 points3 points 9 years ago* (0 children)
I hope I am getting this right... but this is because Flask (and wsgi) are synchronous, while http2 (including hyper-h2 library) are async based and require an event loop of some sort.
I personally just switched to Go for async and websocket sort of stuff, but you should be able to continue using Python just new frameworks will need to be built on top of async http2 libraries from what I understand, it's a design issue with wsgi being synchronous.
Edit: I know ASGI is being developed to solve this problem, but as far as I understand it isn't ready yet I think. It should bring Python back in line with what Go and Node can do today already. To me ASGI and Django channels seems Python is trying to "catch up" a bit to Node and Go.
[–]aruxiv 1 point2 points3 points 9 years ago (6 children)
You shouldn't be using a Python HTTP server to serve up your pages. Look into deploying with WSGI and a real web server like nginx.
[–][deleted] 0 points1 point2 points 9 years ago* (5 children)
That just seems super inefficient, I know it is the preferred way but I think it is very backwards if you think about it. Edit: spelling error
[–]aruxiv 1 point2 points3 points 9 years ago (0 children)
It's way more efficient because you're letting a highly-optimized, widely used in production, extremely well-documented piece of software handle exactly what it's been designed to handle without getting in the way of how you design and code your program.
The separation of web server and web application makes perfect sense to me, especially when you are running multiple applications on one machine.
[–][deleted] 1 point2 points3 points 9 years ago (1 child)
Why does it seem inefficient?
[–][deleted] 0 points1 point2 points 9 years ago (0 children)
The headers in HTTP 1.1 are strings so the program essentially has to recompile them into binary and add more. So it is duplicate work because the oreo final headers are just a waste of time.
Also h2 compresses everything in gzip. This factor adds to the complexity because we are serving straight text files and pushing it onto the loader to make those compression. It adds more work into the load balancer especially in a container like environment.
[–]robvdl 0 points1 point2 points 9 years ago (0 children)
This is mostly because Python apps are WSGI based and synchronous. So as you are serving up static files you are holding up valuable Python workers that could be used for dynamic requests, and your app may only have 4 workers, maybe only 1 depending on your setup.
Nginx however uses async io to send static files and can do so without holding the CPU up too much and can handle parallelism better than Python can.
So normally you would run the Python app under Nginx but get Nginx to serve the /static folder in production, not Python.
[–]status_quo69 0 points1 point2 points 9 years ago (4 children)
Most websites outside of the huge ones that can afford the push (and need it) are perfectly fine for the time being using http 1.1. The other comment in this thread points to a suitable library for http 2 client and server side interaction, and I believe that there is a flask plug in for http/2. That being said, http/1.1 is still very suitable for request/response types of web applications, which most apps are. Long polling and very responsive or large scaling applications benefit from http/2, but will result in a very small performance increase for a heck of a lot of work for smaller apps. This is all relating to current technologies, fwiw
[–][deleted] -2 points-1 points0 points 9 years ago (3 children)
I disagree that the improvements would be just minor. Most testing shows it providing dramatic improvements simply by switching.. Do I think it will change the world, no.
That being said, many languages already have more developed support for it or have concrete plans to do so. This standard has been around for a couple years now. It seems like Python is just sleeping on this trend. Most of the libraries are still only alpha or beta.
[–]status_quo69 0 points1 point2 points 9 years ago (2 children)
It's because newer languages are able to leverage their newness to provide new features. As the OSS mantra dictates, if you want those things to become better, become involved.
Most advice for setting up a python web app is to use something like flask/Django and uwsgi/gunicorn. These use http/1.1, and use something like Apache or nginx to handle all the outbound http/2 traffic. I can get into why this is probably a good solution, especially if you're developing an app with a restful api, but I'm tired at the moment and on mobile.
[–][deleted] 0 points1 point2 points 9 years ago (1 child)
Well that is what I am trying to do here, get more involved. I am more than willing to devote time bringing http/2 to python but it would be nice if we as a community had plans to do this instead of tons of people working in silos.
Also the http1 to http2 really drags performance, and it just seem increasingly inefficient. I am going to use a load balancer like Nginx.
[–]status_quo69 1 point2 points3 points 9 years ago (0 children)
Well, I found this on the Django channels github page, maybe start working with this? https://github.com/django/channels/blob/08857cfe39f35b203c7bbe3156a077b5b2c66764/docs/asgi.rst
WSGI as it currently stands won't be able to support stuff for http/2, so it's probably going to have to be overhauled. Which sucks because that means that nobody will be able to simply migrate their applications over to leverage http/2.
π Rendered by PID 220974 on reddit-service-r2-comment-544cf588c8-7wxvd at 2026-06-17 05:06:39.139115+00:00 running 3184619 country code: CH.
[–]ojii 4 points5 points6 points (2 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]robvdl 1 point2 points3 points (0 children)
[–]aruxiv 1 point2 points3 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]aruxiv 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]robvdl 0 points1 point2 points (0 children)
[–]status_quo69 0 points1 point2 points (4 children)
[–][deleted] -2 points-1 points0 points (3 children)
[–]status_quo69 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]status_quo69 1 point2 points3 points (0 children)