Why is there no `builtins` package in PyPi?

Why does https://pypi.org/project/builtins/ not exist?

The builtins module ships with python and is “built in”,
There is no need for a PyPi package.

What are you trying to do?

Why would you expect it to? What functionality do you think it should implement, and why?

Quicker updates to components, since builtins is a module like any other, right? It’s like an Android OTA system update versus an update from the package manager (F-Droid, Google Play) to a specific package.

builtins is “just a module” (scare quotes mine), but as its name implies, it’s built directly into the interpreter and cannot be updated separately.

Also note that no standard library modules receive updates from PyPI. There are some cases where there is a similarly-named and closely related package on PyPI (importlib-metadata ↔ importlib.metadata comes to mind), but even in those cases the PyPI package is imported differently (e.g., import importlib_metadata as imd vs from importlib import metadata as imd).

1 Like

Thanks, @zware. I wish we had the Q&A module on this Discourse instance, because I’d mark yours as the Answer.

There is one case (turtle) where a same-named, unrelated package is on PyPI. Current policy is to forbid those, but this one dates to before the policy was enacted… I’m nominally working on that, but the PEP 517 process seems to be very, very slow.

1 Like

We do now! I’ve solely marked the undermentioned as so in its stead because it includes the entirety of yours, plus additional context.


Relevantly, I’ve since located the undermentioned, which elaborate:

  1. Is it possible to get pip to install those modules while pip is installing my package, or do I just have to trust that because the user has Python installed they will also have Tkinter and time installed?

    [1]

  2. Regarding the upgrades of the built-in libraries: NO, you cannot do this. Because they are part of the python setup, not of the application environment. Python is very tightly bound to the specific code in those libraries. All python apps & libs expect the same behavior of those libraries, even if they are buggy.

    In addition to that, you cannot install a module/package with the same name as one of the python’s builtins, because it will create the ambiguity on import, and can confuse/break all other libraries which depend on it (or worse, the system applications if you install it into the system python).

    [2]

I presume that this is partially due to what 76643370/1 explains:

The module builtins holds a bunch of “built-in” functions, which are so regularly needed that the language makes them available to your programs implicitly without you needing to explicitly import them. This is merely as a convenience for the programmer. You can explicitly import builtins if you need to, but usually you don’t (because the contents of builtins is already available in every module).


  1. stackoverflow.com/revisions/46868526/1 ↩︎

  2. 46868885/2 ↩︎