⚡ Bolt: Optimize XLSX scanning with direct XML parsing#6
Conversation
Replaces `openpyxl` with `zipfile` and `xml.etree.ElementTree` for scanning Excel files in `recalc.py`. This optimization: - Improves performance by ~3x (0.37s -> 0.11s on benchmark). - Removes runtime dependency on `openpyxl` for this script. - Reduces memory usage by streaming XML instead of building an object model. - Correctly handles formula counting and error detection (inline and shared strings) in a single pass. Co-authored-by: timteh <211128536+timteh@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
⚡ Performance Improvement
Optimized
skills/xlsx/recalc.pyby replacing theopenpyxllibrary with a customfast_scan_xlsxfunction that uses Python's built-inzipfileandxml.etree.ElementTree.Why:
The previous implementation opened the workbook twice (once for errors, once for formulas) because
openpyxl'sdata_onlymode makes it mutually exclusive to see formula strings vs. calculated values. Additionally, loading the full object model (even in read-only mode) has overhead.What Changed:
fast_scan_xlsxwhich streams the XML components of the.xlsxfile.sharedStrings.xml(if present) to identify strings containing errors.<f>tags) and identify errors (t="e", inline strings, or shared strings matching errors) in a single pass.openpyxlimport fromrecalc.py.Impact:
openpyxldependency for this script.Verification:
openpyxlbehavior using a complex test case with various error types (#DIV/0!, #REF!, inline strings, shared strings).PR created automatically by Jules for task 6779280574026263550 started by @timteh