Skip to content

⚡ Bolt: Optimize XLSX scanning with direct XML parsing#6

Open
timteh wants to merge 1 commit intomainfrom
bolt-xlsx-optimization-6779280574026263550
Open

⚡ Bolt: Optimize XLSX scanning with direct XML parsing#6
timteh wants to merge 1 commit intomainfrom
bolt-xlsx-optimization-6779280574026263550

Conversation

@timteh
Copy link
Copy Markdown
Owner

@timteh timteh commented Jan 31, 2026

Performance Improvement

Optimized skills/xlsx/recalc.py by replacing the openpyxl library with a custom fast_scan_xlsx function that uses Python's built-in zipfile and xml.etree.ElementTree.

Why:
The previous implementation opened the workbook twice (once for errors, once for formulas) because openpyxl's data_only mode 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:

  • Implemented fast_scan_xlsx which streams the XML components of the .xlsx file.
  • It parses sharedStrings.xml (if present) to identify strings containing errors.
  • It iterates through worksheets to count formulas (<f> tags) and identify errors (t="e", inline strings, or shared strings matching errors) in a single pass.
  • Removed openpyxl import from recalc.py.

Impact:

  • Speed: ~3x faster on benchmark (1000 rows).
  • Dependencies: Removed openpyxl dependency for this script.
  • Memory: Lower memory footprint due to streaming XML parsing.

Verification:

  • Verified correctness against openpyxl behavior using a complex test case with various error types (#DIV/0!, #REF!, inline strings, shared strings).
  • Verified performance using a benchmark script.

PR created automatically by Jules for task 6779280574026263550 started by @timteh

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>
@google-labs-jules
Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant