84 points · by jwilk · 4y ago · 60 comments
Here are some features I miss regularly and I believe should be part of the standard library:
- support for modern compression algorithms (e.g. brotli, zstandard)
- support for modern hashing algorithms (e.g. argon2, bcrypt)
- support for parsing ISO 8601 date times with "Z" as timezone designator
- a TTL-cache implementation (like cachetools offers)
- support for reading/writing YAML
PHP's base_convert() equivalent.
colorsys
fileinput
getopt
optparse
wave
https://peps.python.org/pep-0594/#modules-to-keepSeems like the maintainers have been generous in deciding which batteries are not dead yet.
colorsys: a small handful of conversion functions you need every now and then
fileinput: quick and dirty boilerplate for when you want to accept input from files or stdin
getopt: a fine, well understood command line parser
optparse: it's a simpler more broken argparse that will eventually tell you "i'm sorry dave..." and people should stop using it
wave: great way to create or process pcm audio data without a whole framework
[1] - https://github.com/python/cpython/blob/main/Lib/argparse.py
There has been an open bug for this for many years.
it's also valid to suggest that a plate of spaghetti is better than a cauldron full (thus favoring optparse).
https://lwn.net/ml/python-dev/CABqyc3wGDmdnDjrhYh0SxT_Tgr5M8...
From: Victor Stinner <vstinner-AT-python.org>
To: Python Dev <Python-Dev-AT-python.org>
Subject: [Python-Dev] It's now time to deprecate the stdlib urllib module
Date: Sun, 06 Feb 2022 15:08:40 +0100
Message-ID: <CABqyc3wGDmdnDjrhYh0SxT_Tgr5M8Za3JTw4CUapnSOVQ-ci3A@mail.gmail.com>
Hi,
I propose to deprecate the urllib module in Python 3.11. It would emit
a DeprecationWarning which warn users, so users should consider better
alternatives like urllib3 or httpx: well known modules, better
maintained, more secure, support HTTP/2 (httpx), etc.Edit: So who maintains urllib, a dependency for the "better" libraries, if you push it out of python core?
Most of the examples show spinning up and listening to a port, but you can google around to find examples that work with just stdin/stdout.
#!/usr/bin/env python
from wsgiref.handlers import CGIHandler
def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return [
b"<html><head><title>foo</title></head><body>bar</body></html>\n"
]
if __name__ == '__main__':
CGIHandler().run(app)You're missing the point (and the hundreds of comments in the three years this pep has been open and debated)--the cgi library never would have been included in python if it were proposed today. It doesn't meet the bar for including in the core just like modules to handle json-rpc, grpc, etc. aren't included today. If you want cgi support pull in a high quality third party library to do it.
I get the arguments for a small standard library in theory, but given how absolutely nightmarish it is to deal with python requirements in a "will work every time" way, I don't know where we end up with the Python standard library in general.
Not making a slippery slope argument for the list of packages in this change. Just like, even when languages like Rust build for the ground up with good package management, everything requires 1000 different packages and it's a whole thing.
So if you don't have a great way of shipping dependencies, and on top of that the standard library is in "please don't let me get bigger", it makes me a bit sad.
(I mean, I don’t care. I use Rust. I’m just arguing on behalf of the poor people who are still abused by their employers, or wacky enough to voluntarily choose to use Python.)
Cgi is still the simplest way to get a basic web script running, without worrying about lingering state between page hits, etc. Doesn't Linus always shut down such discussions regarding the Linux kernel with "we don't break userspace"? Python should learn something from that.
Here’s an example for those interested: https://dzone.com/articles/python-simple-http-server-with-cg...
I remember reading somewhere that amazon.com was originally implemented as CGI's written in C. And, Perl cgi scripts served the whole web for many years, on servers much slower than what we have now.
Removing some batteries just means a couple more pip installs
Put everything in the standard library, or nothing at all, it doesn't really matter. Either way you still have to set up a custom environment and install a bunch of extra stuff and learn "how to run Python programs".
But to answer your question, yes, millions of people run Python programs without ever knowing anything about Python.
To give one example: Every Dropbox customer does, since their client is written in Python
Spoiler: no
Just ask for more money, no reason Dropbox or Amazon can't pay for development. I'm worried this is going to break some use cases, not everyone has network access to install random pip packages
Lucky that the lack of network access will prevent these new versions of Python just as well.
But airgap install of pip packages with myriad dependencies can be annoying.
So I agree with parent comment that having standard packages make things easier
The reality is that it’s acceptable for a few people in absurdly rare edge cases to have a bit of trouble, when it’s justified by much greater gain for everyone else.