PyCG: Practical Call Graph Generation in Python
Not on the map. Why?
Abstract (arXiv)
Call graphs play an important role in different contexts, such as profiling and vulnerability propagation analysis. Generating call graphs in an efficient manner can be a challenging task when it comes to high-level languages that are modular and incorporate dynamic features and higher-order functions. Despite the language's popularity, there have been very few tools aiming to generate call graphs for Python programs. Worse, these tools suffer from several effectiveness issues that limit their practicality in realistic programs. We propose a pragmatic, static approach for call graph generation in Python. We compute all assignment relations between program identifiers of functions, variables, classes, and modules through an inter-procedural analysis. Based on these assignment relations, we produce the resulting call graph by resolving all calls to potentially invoked functions. Notably, the underlying analysis is designed to be efficient and scalable, handling several Python features, such as modules, generators, function closures, and multiple inheritance. We have evaluated our prototype implementation, which we call PyCG, using two benchmarks: a micro-benchmark suite containing small Python programs and a set of macro-benchmarks with several popular real-world Python packages. Our results indicate that PyCG can efficiently handle thousands of lines of code in less than a second (0.38 seconds for 1k LoC on average). Further, it outperforms the state-of-the-art for Python in both precision and recall: PyCG achieves high rates of precision ~99.2%, and adequate recall ~69.9%. Finally, we demonstrate how PyCG can aid dependency impact analysis by showcasing a potential enhancement to GitHub's "security advisory" notification service using a real-world example.
Key facts. Cited by 16 papers in the map (data through 7 Oct 2026). First posted on arXiv 28 Feb 2021.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2022: 2; 2023: 3; 2024: 2; 2025: 1; 2026: 8.
16 papers.
Sort:
By area:
- 2024AutoCodeRover: Autonomous Program Improvementcited by 272
- 2022AutoPruner: Transformer-Based Call Graph Pruningcited by 11
- 2023Efficient Query-Based Attack against ML-Based Android Malware Detection under Zero Knowledge Settingcited by 10
- 2024Enhancing Differential Testing With LLMs For Testing Deep Learning Librariescited by 4
- 2026Multi-Agent Taint Specification Extraction for Vulnerability Detectioncited by 3
- 2023KGLiDS: A Platform for Semantic Abstraction, Linking, and Automation of Data Sciencecited by 2
- 2025An Empirical Study of Vulnerabilities in Python Packages and Their Detectioncited by 2
- 2026An Execution-Verified Multi-Language Benchmark for Code Semantic Reasoningcited by 1
- 2026How Much Static Structure Do Code Agents Need? A Study of Deterministic Anchoringcited by 1
- 2026RepoRescue: An Empirical Study of LLM Agents on Whole-Repository Compatibility Rescuecited by 1
- 2026Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generationcited by 1
- 2022Topical: Learning Repository Embeddings from Source Code using Attentioncited by 0
4 more
- 2023Understanding the Complexity and Its Impact on Testing in ML-Enabled Systemscited by 0
- 2026DepRadar: Agentic Coordination for Context Aware Defect Impact Analysis in Deep Learning Librariescited by 0
- 2026M2K: Making the Model-Kernel Interface Explicit for Reliable CUDA Kernel Verificationcited by 0
- 2026RepoAtlas: Guiding Coding Agents via Evolving Multimodal Repository Viewscited by 0
- 2026RepoAtlas: Guiding Coding Agents via Evolving Multimodal Repository Views15 Sep 2026
- 2026Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generation3 Aug 2026
- 2026RepoRescue: An Empirical Study of LLM Agents on Whole-Repository Compatibility Rescue1 Jul 2026
- 2026How Much Static Structure Do Code Agents Need? A Study of Deterministic Anchoring25 Jun 2026
- 2026An Execution-Verified Multi-Language Benchmark for Code Semantic Reasoning10 May 2026
- 2026M2K: Making the Model-Kernel Interface Explicit for Reliable CUDA Kernel Verification6 Mar 2026
- 2026Multi-Agent Taint Specification Extraction for Vulnerability Detection15 Jan 2026
- 2026DepRadar: Agentic Coordination for Context Aware Defect Impact Analysis in Deep Learning Libraries14 Jan 2026
- 2025An Empirical Study of Vulnerabilities in Python Packages and Their Detection4 Sep 2025
- 2024Enhancing Differential Testing With LLMs For Testing Deep Learning Libraries12 Jun 2024
- 2024AutoCodeRover: Autonomous Program Improvement8 Apr 2024
- 2023Efficient Query-Based Attack against ML-Based Android Malware Detection under Zero Knowledge Setting5 Sep 2023
4 more
- 2023KGLiDS: A Platform for Semantic Abstraction, Linking, and Automation of Data Science3 Mar 2023
- 2023Understanding the Complexity and Its Impact on Testing in ML-Enabled Systems10 Jan 2023
- 2022AutoPruner: Transformer-Based Call Graph Pruning7 Sep 2022
- 2022Topical: Learning Repository Embeddings from Source Code using Attention19 Aug 2022
- 2026Multi-Agent Taint Specification Extraction for Vulnerability Detectioncited by 3
- 2026How Much Static Structure Do Code Agents Need? A Study of Deterministic Anchoringcited by 1
- 2026RepoRescue: An Empirical Study of LLM Agents on Whole-Repository Compatibility Rescuecited by 1
- 2026DepRadar: Agentic Coordination for Context Aware Defect Impact Analysis in Deep Learning Librariescited by 0
- 2026RepoAtlas: Guiding Coding Agents via Evolving Multimodal Repository Viewscited by 0
- 2026RepoAtlas: Guiding Coding Agents via Evolving Multimodal Repository Views15 Sep 2026
- 2026RepoRescue: An Empirical Study of LLM Agents on Whole-Repository Compatibility Rescue1 Jul 2026
- 2026How Much Static Structure Do Code Agents Need? A Study of Deterministic Anchoring25 Jun 2026
- 2026Multi-Agent Taint Specification Extraction for Vulnerability Detection15 Jan 2026
- 2026DepRadar: Agentic Coordination for Context Aware Defect Impact Analysis in Deep Learning Libraries14 Jan 2026
- 2024AutoCodeRover: Autonomous Program Improvementcited by 272
- 2022AutoPruner: Transformer-Based Call Graph Pruningcited by 11
- 2023Efficient Query-Based Attack against ML-Based Android Malware Detection under Zero Knowledge Settingcited by 10
- 2024Enhancing Differential Testing With LLMs For Testing Deep Learning Librariescited by 4
- 2023KGLiDS: A Platform for Semantic Abstraction, Linking, and Automation of Data Sciencecited by 2
- 2025An Empirical Study of Vulnerabilities in Python Packages and Their Detectioncited by 2
- 2022Topical: Learning Repository Embeddings from Source Code using Attentioncited by 0
- 2023Understanding the Complexity and Its Impact on Testing in ML-Enabled Systemscited by 0
- 2026M2K: Making the Model-Kernel Interface Explicit for Reliable CUDA Kernel Verificationcited by 0
- 2026M2K: Making the Model-Kernel Interface Explicit for Reliable CUDA Kernel Verification6 Mar 2026
- 2025An Empirical Study of Vulnerabilities in Python Packages and Their Detection4 Sep 2025
- 2024Enhancing Differential Testing With LLMs For Testing Deep Learning Libraries12 Jun 2024
- 2024AutoCodeRover: Autonomous Program Improvement8 Apr 2024
- 2023Efficient Query-Based Attack against ML-Based Android Malware Detection under Zero Knowledge Setting5 Sep 2023
- 2023KGLiDS: A Platform for Semantic Abstraction, Linking, and Automation of Data Science3 Mar 2023
- 2023Understanding the Complexity and Its Impact on Testing in ML-Enabled Systems10 Jan 2023
- 2022AutoPruner: Transformer-Based Call Graph Pruning7 Sep 2022
- 2022Topical: Learning Repository Embeddings from Source Code using Attention19 Aug 2022