On Mon, 25 Sep 2017 10:03 am, Stefan Ram wrote:
> What's the difference between ?builtins? and ?_sitebuiltins??
> |>>> type.__module__
> |>>> help.__module__
> I mean the semantic difference. Why are some entities placed
> into ?builtins? and some into ?_sitebuiltins??
Read the source. The _sitebuiltins module says:
The objects used by the site module to add custom builtins.
# Those objects are almost immortal and they keep a reference to their module
# globals. Defining them in the site module would keep too many references
# Note this means this module should also avoid keep things alive in its
Historically, the content of _sitebuiltins.py used to be in site.py. So it's
just an implementation detail: site.py was refactored to keep long-lasting
objects separate from those that are ephemeral.
`builtins` is the official public name of the built-in namespace. In Python 2,
it was unfortunately called __builtin__.
Unfortunately there is also a __builtins__ name, which is a private, CPython
implementation detail. Ignore it.
?Cheer up,? they said, ?things could be worse.? So I cheered up, and sure
enough, things got worse.