Sitelet https://github.com/starkware-libs/cairo/pull/10125
Skip to content

refactor(utils): Removed write_comma_separated using equivalent .format all around. - #10125

Merged
orizi merged 1 commit into
mainfrom
orizi/06-18-refactor_utils_removed_write_comma_separated_using_equivalent_.format_all_around
Jun 18, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/06-18-refactor_utils_removed_write_comma_separated_using_equivalent_.format_all_around

Conversation

@orizi

@orizi orizi commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Removes the custom write_comma_separated utility function from cairo-lang-utils and replaces all call sites with itertools's format and format_with methods, which provide equivalent functionality more idiomatically.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

write_comma_separated duplicated functionality already available via itertools::Itertools::format and format_with. Removing it reduces maintenance burden and consolidates formatting logic around the already-present itertools dependency.


What was the behavior or documentation before?

Comma-separated formatting in Display implementations was handled by a custom write_comma_separated function in cairo-lang-utils, requiring multiple write! calls (one for the opening delimiter, one for the content, one for the closing delimiter).


What is the behavior or documentation after?

The same formatting is achieved using itertools's .format(", ") and .format_with(", ", ...), allowing the entire formatted output to be expressed in a single write! call with inline format strings.


Related issue or discussion (if any)

N/A


Additional context

The write_comma_separated function and its associated use core::fmt import have been fully removed from cairo-lang-utils/src/lib.rs. All previously dependent crates (cairo-lang-executable, cairo-lang-sierra-generator, cairo-lang-sierra-to-casm, cairo-lang-sierra) now import itertools::Itertools directly.

orizi commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@orizi
orizi marked this pull request as ready for review June 18, 2026 08:37
@cursor

cursor Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Display-only refactor with no logic, API, or security changes; output formatting should be equivalent.

Overview
Removes write_comma_separated from cairo-lang-utils and switches comma-separated Display formatting to itertools (.format(", ") and .format_with) in executable compile output, pre-Sierra PushValues, CASM reference cells, and Sierra program pretty-printing.

Call sites collapse multi-step write! sequences into single format strings; behavior should match the old helper. cairo-lang-utils drops the unused core::fmt import tied to that function.

Reviewed by Cursor Bugbot for commit c840412. Bugbot is set up for automated code reviews on this repo. Configure here.

@orizi
orizi changed the base branch from orizi/06-18-performance_general_rewrite_join_into_format_-_removing_intermediary_strings to graphite-base/10125 June 18, 2026 09:00

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:lgtm:

@TomerStarkware reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

@orizi
orizi force-pushed the orizi/06-18-refactor_utils_removed_write_comma_separated_using_equivalent_.format_all_around branch from 9bba9d0 to c840412 Compare June 18, 2026 09:29
@orizi
orizi force-pushed the graphite-base/10125 branch from 3ace186 to 77005ea Compare June 18, 2026 09:29
@orizi
orizi changed the base branch from graphite-base/10125 to main June 18, 2026 09:29
@orizi
orizi enabled auto-merge June 18, 2026 09:30
@orizi
orizi added this pull request to the merge queue Jun 18, 2026
Merged via the queue into main with commit 8914649 Jun 18, 2026
106 checks passed
@orizi
orizi deleted the orizi/06-18-refactor_utils_removed_write_comma_separated_using_equivalent_.format_all_around branch June 21, 2026 12:15
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.

3 participants