Python 3.15: A Critical Operations Update for Data Teams, Not Just a Speed Boost
A key operational change in Python 3.15 is the deprecation of .pth import lines in favor of .start files, which provide a more auditable and secure way to execute startup code. This change aims to reduce the attack surface for credential-harvesting malware, as demonstrated by the compromised litellm 1.82.7 and 1.82.8 releases. The new .start files allow for entry points to be defined in a module, making it easier to audit and manage startup code execution.
The article provides a runbook for profiling stuck jobs, including commands to dump and attach profilers, and emphasizes the need for precise interpreter versions and proper CAP_SYS_PTRACE permissions. It also outlines a startup code audit tool that lists all startup hooks in an environment, helping teams identify and manage potential security risks.
For data teams, Python 3.15 offers practical benefits such as improved profiling capabilities, better security through auditable startup code, and operational reliability. The article advises teams to measure performance with -X importtime, add lazy imports to entry points, and implement startup code audits in their build processes. These changes help prevent issues like slow startup times, stuck jobs, and security vulnerabilities that could impact production systems.
