by eterevsky · 4y ago · 0 comments
- array: everyone uses numpy for the same purposes
- bisect: very niche feature, not a good fit for standard library
- glob: should probably be part of os
- graphlib: why is it part of the standard library? even if you need to work with graphs, chances are you have different requirements or data format
- shlex: again, not really necessary in standard library (unless it's used in shutil, I don't know)
- statistics: should be handled by scipy
And that's just the modules mentioned in this article. There are tons of other modules that are outdated, unused, don't fit into standard library: getopt, curses, urllib (everyone uses requests), xml*, html, tkinter.
What Python should be doing is deprecating those modules and/or moving them outside of the standard library. Not adding more of them.
For that, some of the included libraries really ease the pain of having to reinvent things like text-wrapping, special cases when iterating over things, creating TUIs, etc.
The more you read the docs, the more you appreciate the thought and effort of the Python developers in making things useful and convenient for everyone.
To me, the breadth of the standard library is one of Python’s main strengths.
This is what will be (eventually) removed: https://docs.python.org/3/library/superseded.html
> urllib (everyone uses requests)
iirc requests is actually a wrapper for urllib. And there are certainly many scripts using urllib directly to avoid having an out-of-stdlib dependency. The API is not that bad.
For example some modules are not what they seem to be; graphlib doesn't purport to be a general graph library and statistics doesn't mean to replace scipy. They are just groups for otherwise independent bits of code, named so that similar future code can be grouped together. In some cases you have a waaaaaay too high threshold for "unused" modules, for example [1] kept getopt because it mirrors a popular C library.
It's an excellent reason to keep it as a separately maintained module. Having in the standard library two modules for the same purpose just adds to the confusion.
Having them included by default is much more convenient; I may want to do some very simple stats without needing all of scipy, etc.
My usage is generally lists for small stuff where I don't care about performance, and pandas/numpy for analysis. So maybe array is either if I don't want numpy, or if I am doing something real and large and list performance would truly be a problem?
Also, I looked for a PEP to answer these questions and couldn't find it. (The one I found was very old). Or any stats on performance improvements?
I also think having basic statistic computations is useful. There are people who may want to calculate simple statistics without adding a whole dependency.
I don't want a dependency on NumPy, especially as I don't need any other feature of NumPy beyond storing a homogeneous, resizeable vector of simple data types.
No, thanks.
It still is used in situations where numpy doesn't fit (serialization of data, etc)
Agree with shlex and glob
> statistics: should be handled by scipy
It was just added. I guess for people who want to import numpy to calculate the mean of an array? (please don't do this - you don't need to do this)
getopt is a needed evil and I think requests uses a lot of builtin stuff
Python does deprecate some modules once in a while
For one thing, you can pry Tkinter from my cold dead hands. For another, I used array just last week.
This whole "no one is using it so throw it away" culture is part of the improving-to-death of the modern Python ecosystem. I think it must come from the Python 3 fiasco. It's become fashionable in a subset of Python community to aggressively deprecate working code.