_sitebuiltins?

Chris Angelico rosuav at gmail.com
Sun Sep 24 20:13:26 EDT 2017


On Mon, Sep 25, 2017 at 10:03 AM, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
>   What's the difference between »builtins« and »_sitebuiltins«?
>
> |>>> type.__module__
> |'builtins'
> |
> |>>> help.__module__
> |'_sitebuiltins'
>
>   I mean the semantic difference. Why are some entities placed
>   into »builtins« and some into »_sitebuiltins«?

Because the 'help' function comes from site.py:

def sethelper():
    builtins.help = _sitebuiltins._Helper()

If you're not importing site.py (eg "python3 -S"), you don't need the
code for help(), but you'll always have type().

Basically it's a memory-saving thing. Critical vs optional.

ChrisA



More information about the Python-list mailing list