Nuitka/Nuitka

caching of Python -> C sources for faster incremental builds

Open

#3,710 创建于 2026年1月4日

在 GitHub 查看
 (3 评论) (2 反应) (1 负责人)Python (10,351 star) (565 fork)batch import
enhancementhelp wantedscalability

描述

🐛 Bug Description

This would be a performance improvement where we cache generated C source files so incremental rebuilds can skip C code generation for unchanged modules. I have a working implementation and a PR ready plus some tests and promising results. I'm opening this issue to discuss the proposal and results.

🖥️ Environment

1. Nuitka Version, Python Version, OS, and Platform

python -m nuitka --version 4.0rc5 Commercial: None Python: 3.11.11 | packaged by conda-forge | (main, Mar 3 2025, 20:29:43) [MSC v.1943 64 bit (AMD64)] Flavor: Anaconda Python Executable: ~\anaconda\python.exe OS: Windows Arch: x86_64 WindowsRelease: 11 Version C compiler: cl (cl 14.3).

2. How Nuitka and Python were Installed

Nuitka: git clone (develop). Python: Anaconda (conda‑forge).

3. Relevant PyPI Packages and Versions

Not relevant for this feature.

🛠️ To Reproduce

1. "Hello World" Test (if applicable)

N/A

2. Short, Self-Contained, Correct, Eligible (SSCCE) Example

N/A i think. The implementation is available on my branch.

3. Nuitka Command Line Options

State the Nuitka options used. Ideally, use # nuitka-project: options in your code.

Example commands used for measurement:

python -m nuitka --devel-profile-compilation test_caching.py python -m nuitka --follow-imports test_caching.py

📉 Expected Behavior

Incremental rebuilds should reuse cached C source for unchanged modules, reducing compile time without changing output.

📄 Actual Behavior & Output

With the cache enabled (implementation in PR):

  • Codegen‑only timing: 0.125s cold → 0.016s warm (~87.5% faster).
  • End‑to‑end multi‑module (stdlib) benchmark:
    • 10 modules: 17.35s → 14.68s (15.4% faster)
    • 25 modules: 46.85s → 45.42s (3.1% faster)
    • 50 modules: 81.12s → 45.46s (44.0% faster)

Cache hit/miss behavior is correct (cold miss, warm hit).

↩️ Regression (if applicable)

N/A

💡 Additional Context (Optional)

if this aligns with your vision for nuitka see here for my implementation + correctness test

贡献者指南