◐ Shell
clean mode source ↗

Message 280261 - Python tracker

Oh, I understood why I had issues to reproduce the startup performance slowdown. When Python is run from the source code using ./python, the re module is not imported. When Python is installed, the re is not imported by default neither:

haypo@speed-python$ prefix/bin/python3 -c 'import sys; print("re" in sys.modules)'
False


BUT when Python is started from a virtual environment (created by the "venv" module), the re module is important by default.

haypo@speed-python$ venv/bin/python3 -c 'import sys; print("re" in sys.modules)'
True


If the site module is not imported, the re module is not imported:

haypo@speed-python$ venv/bin/python3 -S -c 'import sys; print("re" in sys.modules)'
False


The /home/haypo/benchmarks/prefix/lib/python3.6/site.py file is generated by the venv module and contains:

def venv(...):
    ...
    if candidate_confs:
        import re
        config_line = re.compile(CONFIG_LINE)
        ...