DynaPyt: a dynamic analysis framework for Python
Aryaz Eghbali, Michael Pradel
Abstract
Python is a widely used programming language that powers important application domains such as machine learning, data analysis, and web applications. For many programs in these domains it is consequential to analyze aspects like security and performance, and with Python's dynamic nature, it is crucial to be able to dynamically analyze Python programs. However, existing tools and frameworks do not provide the means to implement dynamic analyses easily and practitioners resort to implementing an ad-hoc dynamic analysis for their own use case. This work presents DynaPyt, the first general-purpose framework for heavy-weight dynamic analysis of Python programs. Compared to existing tools for other programming languages, our framework provides a wider range of analysis hooks arranged in a hierarchical structure, which allows developers to concisely implement analyses. DynaPyt features selective instrumentation and execution modification as well. We evaluate our framework on test suites of 9 popular open-source Python projects, 1,268,545 lines of code in total, and show that it, by and large, preserves the semantics of the original execution. The running time of DynaPyt is between 1.2x and 16x times the original execution time, which is in line with similar frameworks designed for other languages, and 5.6%-88.6% faster than analyses using a built-in tracing API offered by Python. We also implement multiple analyses, show the simplicity of implementing them and some potential use cases of DynaPyt. Among the analyses implemented are: an analysis to detect a memory blow up in Pytorch programs, a taint analysis to detect SQL injections, and an analysis to warn about a runtime performance anti-pattern.
• General and reference → Cross-computing tools and techniques; • Software and its engineering → Software maintenance tools.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 8236008a-66bb-40f9-9133-d19343995950Cited by top-tier papers12
- The evolution of type annotations in python: an empirical studyLuca Di Grazia, Michael PradelFSE 2022 · 29 citations
- You Name It, I Run It: An LLM Agent to Execute Tests of Arbitrary ProjectsIslem Bouzenia, Michael PradelISSTA 2025 · 17 citations
- LExecutor: Learning-Guided ExecutionBeatriz Souza, Michael PradelFSE 2023 · 16 citations
- DyPyBench: A Benchmark of Executable Python SoftwareIslem Bouzenia, Bajaj Piyush Krishan, Michael PradelFSE 2024 · 8 citations
- SelfPiCo: Self-Guided Partial Code Execution with LLMsZhipeng Xue, Zhipeng Gao, Shaohua Wang, Xing Hu et al.ISSTA 2024 · 8 citations
Builds on2
Related papers
- DyLin: A Dynamic Linter for PythonAryaz Eghbali, Felix Burk, Michael PradelFSE 2025 · 1 citation
- SlipCover: Near Zero-Overhead Code Coverage for PythonJuan Altmayer Pizzorno, Emery D. BergerISSTA 2023 · 11 citations
- PYLIVE: On-the-Fly Code Change for Python-based Online ServicesHaochen Huang, Chengcheng Xiang, Li Zhong, Yuanyuan ZhouUSENIX ATC 2021 · 7 citations
- PyAnalyzer: An Effective and Practical Approach for Dependency Extraction from Python CodeWuxia Jin, Shuo Xu, Dawei Chen, Jiajun He et al.ICSE 2024 · 4 citations
- HARP: holistic analysis for refactoring Python-based analytics programsWeijie Zhou, Yue Zhao, Guoqiang Zhang, Xipeng ShenICSE 2020 · 10 citations
