Which standard library modules are required to run the Python 3.5 interpreter?

前端 未结 3 2033
星月不相逢
星月不相逢 2021-01-05 02:58

Here\'s a CPython program that tries to initialize the interpreter with an empty sys.path:

#include 

int main(int argc, char**          


        
3条回答
  •  Happy的楠姐
    2021-01-05 03:36

    These are packages/modules that are used during interpreter start-up (as, @Charles Duffy noted in a comment, by looking in sys.modules).

    The result depends on whether you have site enabled or not (your Py_NoSiteFlag = 1; implies this isn't the case but anyway, I'll give both options :-)).

    site drags a couple of additional modules with it when you use it like _sitebuiltins and stat, in total you could run Python using only the following:

    abc.py               encodings       os.py         _sitebuiltins.py  sysconfig.py
    codecs.py            genericpath.py  posixpath.py  site.py           _collections_abc.py  
    io.py                stat.py         _weakrefset.py
    

    with site disabled, you're stripped down to the following 6:

    abc.py  codecs.py  encodings  io.py  os.py  _weakrefset.py
    

    when invoked through C with Py_Initialize() (or through Windows based on your comment) I'm guessing os.py might not be actually needed.

提交回复
热议问题