Skip to content

⚡ Bolt: Use CSafeLoader for faster PyYAML parsing#546

Closed
aafre wants to merge 1 commit into
mainfrom
bolt-csafe-loader-8499870962363146812
Closed

⚡ Bolt: Use CSafeLoader for faster PyYAML parsing#546
aafre wants to merge 1 commit into
mainfrom
bolt-csafe-loader-8499870962363146812

Conversation

@aafre
Copy link
Copy Markdown
Owner

@aafre aafre commented May 22, 2026

What: Replaced yaml.safe_load with yaml.load(..., Loader=yaml.CSafeLoader) with a fallback to yaml.SafeLoader across all backend parsing sites.
Why: PyYAML's safe_load defaults to a pure Python implementation which is slower than the C extension for parsing large configuration or data files.
Impact: Faster YAML parsing speed for file loading and DB JSONB conversions, improving latency.
Measurement: Verified optimization via manual local benchmark using test data, and validated with existing test suite using pytest.


PR created automatically by Jules for task 8499870962363146812 started by @aafre

Co-authored-by: aafre <8656674+aafre@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request optimizes PyYAML parsing performance by implementing CSafeLoader with a fallback mechanism across several modules. It also includes a significant codebase-wide reformatting of imports, data structures, and test files to improve consistency. The review feedback suggests specifying explicit UTF-8 encoding when opening files to ensure consistent behavior across different environments.

Comment thread app.py
@@ -838,20 +840,22 @@ def generate_latex_pdf(yaml_data, icons_dir, output_path, template_name="classic
def load_resume_data(yaml_file_path):
"""Load and validate resume data from YAML file."""
with open(yaml_file_path, "r") as file:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When opening text files for reading, it is recommended to specify an explicit encoding (e.g., encoding="utf-8") to ensure consistent behavior across different platforms and environments.

Suggested change
with open(yaml_file_path, "r") as file:
with open(yaml_file_path, "r", encoding="utf-8") as file:

Comment thread app.py
@@ -1897,7 +1918,7 @@ def generate_resume():

# Parse YAML to extract icon references
with open(yaml_path, "r") as f:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Specify an explicit encoding when opening the YAML file to avoid potential issues with platform-dependent default encodings.

Suggested change
with open(yaml_path, "r") as f:
with open(yaml_path, "r", encoding="utf-8") as f:

@aafre
Copy link
Copy Markdown
Owner Author

aafre commented May 25, 2026

Closing duplicate — the most recent version of this change is PR #549.

@aafre aafre closed this May 25, 2026
@google-labs-jules
Copy link
Copy Markdown
Contributor

Closing duplicate — the most recent version of this change is PR #549.

Understood. Acknowledging that this work is now obsolete and stopping work on 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