Skip to content

user variables for scripted cycles#110

Draft
unlessgames wants to merge 3 commits intodevfrom
cycle-user-vars
Draft

user variables for scripted cycles#110
unlessgames wants to merge 3 commits intodevfrom
cycle-user-vars

Conversation

@unlessgames
Copy link
Copy Markdown
Collaborator

@unlessgames unlessgames commented Mar 6, 2026

An initial draft for the discussed vars function on the cycle object.

Works similar to :map in that you can supply either a static table or a function returning a table.

I guess we'll need a different context for vars? Since variables are only being assigned once per generate instead of for each event, the fields related to single steps are meaningless.

Here, the table variant inserts the variables to the cycle directly instead of passing around the table (contrary to the case with map) whereas the callback variant follows a similar pattern to the mapping_function.

Not sure what else should happen with the callback and its errors, but it seems to work fine so far.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

Benchmark for f153fdf

Click to view benchmark
Test Base PR %
Cycle/Generate 52.6±0.71µs 52.4±0.65µs -0.38%
Cycle/Parse 308.2±6.75µs 318.7±5.74µs +3.41%
Rust Phrase/Clone 434.8±5.84ns 420.0±6.61ns -3.40%
Rust Phrase/Create 65.0±1.03µs 67.0±1.62µs +3.08%
Rust Phrase/Run 619.6±5.92µs 626.4±8.75µs +1.10%
Rust Phrase/Seek 127.3±231.54µs 139.1±255.27µs +9.27%
Scripted Phrase/Clone 631.3±10.45ns 623.7±7.86ns -1.20%
Scripted Phrase/Create 1025.9±38.01µs 995.3±18.79µs -2.98%
Scripted Phrase/Run 1657.7±11.40µs 1641.7±16.49µs -0.97%
Scripted Phrase/Seek 214.9±435.32µs 205.1±408.79µs -4.56%

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

Benchmark for c8242c9

Click to view benchmark
Test Base PR %
Cycle/Generate 52.9±0.53µs 52.3±0.34µs -1.13%
Cycle/Parse 316.3±4.35µs 311.9±4.88µs -1.39%
Rust Phrase/Clone 429.8±8.69ns 425.6±12.07ns -0.98%
Rust Phrase/Create 67.0±1.30µs 65.4±1.19µs -2.39%
Rust Phrase/Run 627.1±6.42µs 645.6±4.86µs +2.95%
Rust Phrase/Seek 132.5±242.42µs 135.7±249.90µs +2.42%
Scripted Phrase/Clone 635.6±11.68ns 631.6±5.54ns -0.63%
Scripted Phrase/Create 1017.4±33.02µs 1003.0±34.54µs -1.42%
Scripted Phrase/Run 1657.1±18.77µs 1616.5±20.19µs -2.45%
Scripted Phrase/Seek 215.0±434.49µs 203.8±407.01µs -5.21%

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 6, 2026

Benchmark for 77adad2

Click to view benchmark
Test Base PR %
Cycle/Generate 52.0±0.34µs 52.5±1.54µs +0.96%
Cycle/Parse 315.8±6.34µs 309.2±4.24µs -2.09%
Rust Phrase/Clone 431.8±7.61ns 426.8±6.61ns -1.16%
Rust Phrase/Create 66.6±1.74µs 65.7±2.05µs -1.35%
Rust Phrase/Run 639.5±14.46µs 645.6±6.08µs +0.95%
Rust Phrase/Seek 127.7±231.26µs 136.8±253.06µs +7.13%
Scripted Phrase/Clone 637.1±6.87ns 637.9±11.71ns +0.13%
Scripted Phrase/Create 994.8±18.35µs 1011.6±67.51µs +1.69%
Scripted Phrase/Run 1665.4±11.42µs 1637.2±10.42µs -1.69%
Scripted Phrase/Seek 216.2±437.92µs 214.0±433.11µs -1.02%

@emuell
Copy link
Copy Markdown
Member

emuell commented Mar 6, 2026

Looks great. I'll add a few nitpicking comments in the review and will do more testing over the weekend. Else this looks straight forward and like a really great addition!

@unlessgames
Copy link
Copy Markdown
Collaborator Author

Hey, did you mean that you wanted to add those comments to this as-is, or are you waiting for me here to make the PR more complete? I'd appreciate any nitpicks here before continuing!

@emuell
Copy link
Copy Markdown
Member

emuell commented Apr 1, 2026

There should be a new with_variables_callback instead of adding this into the existing off-topic with_mapping_callback. I can fix that too if you want me to.

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.

2 participants