Watch your Python script with strace
summary
Shows how to use strace/truss to observe actual system calls made by Python and why that matters: /bin/true makes a few dozen calls, an empty Python -c script makes 57 system calls, importing a module can be hundreds (378) and importing large packages in a polluted path can spike to 73,000 syscalls. Demonstrates options (-o trace.txt, -f to follow children), explains buffering hiding writes, recommends comparing a working trace, and recommends ltrace to inspect library calls (useful for SSL plaintext debugging).
AI-written summary · about
chapters (28)
- 0:00Introduction
- 10:56Standard error and exit
- 17:13Tracing a simple command
- 17:55C runtime initialization
- 19:13System call analysis
- 24:30Dynamic library loading
- 26:14System call noise
- 26:28Python startup behavior
- 26:55Python module search
- 27:57Import system calls
- 31:17Virtual environments
- 31:44Easy install vs pip
- 32:05Buildout impact
- 32:15Sys.path issues
- 32:48Importing libraries
- 34:31N-squared complexity
- 34:49Dependency management
- 35:00Python 3 optimizations
- 37:35Debugging imports
- 42:07System call mapping
- 43:18DNS and sockets
- 43:32Man pages and buffering
- 48:00Process termination
- 48:39Threading and children
- 49:01Subprocess management
- 49:28Debugging strategies
- 51:21Ltrace for libraries
- 51:48Conclusion
related talks
27mThe Hidden Power of the Python Runtime
29mUsing strace to troubleshoot issues
41mLinux Tracing Techniques
28mKnocking On A Process’s Door: Introspecting Live Python Processes
29m"from where?!? import what?!?"
01h 31mDebugging and profiling techniques
37mUsing STRACE to troubleshoot issues
37mTuning Python applications can dramatically increase performance
