3

Can I add more modules to the Python Standard Library??? I am aware that one can add more modules in Python, but while using one should install that package using pip. Whereas the modules in Python Standard Library like math, statistics, os, sys, etc. are by default available in one's device once Python is downloaded from web.

Is there any way to include one of my new modules in that Python Standard Library???

1
  • 1
    Well, you can of course write a module and have it added to the standard library. The procedure is to write a PEP explaining why it would be a good idea, and have it accepted by the community. But a change to the standard library would probably have to wait at least until Python 3.10. Could you explain what problem you have that doing this would solve, that making it available on PyPI for installation via pip does not solve? Commented Aug 29, 2020 at 10:09

2 Answers 2

4

If you want to add a module to the Python Standard Library, you essentially have to convince the Python Software Foundation to add it.

Questions you need to be prepared to answer are, among other things:

  • What makes your module so useful and so important that it is worth the cost of every Python developer and every Python user in the world having to pay the cost of downloading it every time they install or update Python?
  • What makes your module so useful and so important that it is worth the cost of the Python Software Foundation having to maintain, support, and fix it for all eternity without ever breaking backwards-compatibility?

Once you have answered those questions, you have to write up a Python Enhancement Proposal (PEP) that specifies the exact behavior of your module, documents the API, explains why the module is useful, how to use it, and why this particular solution is the "right" one and others don't solve the problem. In the PEP, you should also justify why the problem is impossible to solve outside of the standard library. If you are not already a well-known active contributor to Python, you will probably also need to find some sort of sponsor or mentor that speaks up for you and helps you navigate the process.

Here is an example of such a PEP for adding a new module to the stdlib: PEP 603 – Adding a frozenmap type to collections.

The whole process is outlined in chapter 19 Adding to the stdlib, more precisely subsection 19.2 Adding a new module of the Python Developer's Guide.

Here are some of the things to look out for, all mentioned in the Python Developer's Guide [bold emphasis mine]:

It must be stated upfront that getting a new module into the stdlib is very difficult. Adding any significant amount of code to the stdlib increases the burden placed upon core developers. It also means that the module somewhat becomes “sanctioned” by the core developers as a good way to do something, typically leading to the rest of the Python community to using the new module over other available solutions. All of this means that additions to the stdlib are not taken lightly.

Typically two types of modules get added to the stdlib. One type is a module which implements something that is difficult to get right.

The example given for this type of module is multiprocessing.

The second type of module is one that implements something that people re-implement constantly.

itertools is an example for this type.

The following hard requirements are listed:

  • making sure the coding style guides are followed and that the proper tests have been written

  • The module needs to have been out in the community for at least a year.

  • The module needs to be considered best-of-breed.

  • You must give up control of the module and its development and project management needs to move into the Python project.
  • Despite you giving up control, the following is required:

    Someone involved with the development of the module must promise to help maintain the module in the stdlib for two years.

Sign up to request clarification or add additional context in comments.

Comments

0

No, it's not possible. However, you could consider downloading a different python distribution, like Anaconda.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.