Skip to content

feat!: Use mutable structs for std collections and make internals private#1796

Open
mark-koch wants to merge 8 commits into
mainfrom
mk/mutable-collections
Open

feat!: Use mutable structs for std collections and make internals private#1796
mark-koch wants to merge 8 commits into
mainfrom
mk/mutable-collections

Conversation

@mark-koch
Copy link
Copy Markdown
Collaborator

@mark-koch mark-koch commented Jun 2, 2026

Closes #1774

BREAKING CHANGE: Interface of guppylang.std.collections.{Stack, Queue, PriorityQueue} now borrows the queue instead of taking and returning it
BREAKING CHANGE: All fields of guppylang.std.collections.{Stack, Queue, PriorityQueue} are now private

Depends on #1793

@mark-koch mark-koch requested a review from a team as a code owner June 2, 2026 14:44
@mark-koch mark-koch requested review from doug-q and removed request for a team June 2, 2026 14:44
Comment on lines -38 to +40
def __len__(self: PriorityQueue[T, MAX_SIZE]) -> int:
def __len__(self) -> int:
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

driveby: I used some more modern guppy features to make these signatures more compact

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

🐰 Bencher Report

Branchmk/mutable-collections
TestbedLinux
Click to view all benchmark results
Benchmarkhugr_bytesBenchmark Result
bytes x 1e3
(Result Δ%)
Upper Boundary
bytes x 1e3
(Limit %)
hugr_nodesBenchmark Result
nodes
(Result Δ%)
Upper Boundary
nodes
(Limit %)
tests/benchmarks/test_big_array.py::test_big_array_compile📈 view plot
🚷 view threshold
158.77 x 1e3
(0.00%)Baseline: 158.77 x 1e3
160.36 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
6,641.00
(0.00%)Baseline: 6,641.00
6,707.41
(99.01%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile📈 view plot
🚷 view threshold
27.54 x 1e3
(0.00%)Baseline: 27.54 x 1e3
27.81 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
1,074.00
(0.00%)Baseline: 1,074.00
1,084.74
(99.01%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_benchmark_compile📈 view plot
🚷 view threshold
10.94 x 1e3
(+0.32%)Baseline: 10.91 x 1e3
11.02 x 1e3
(99.33%)
📈 view plot
🚷 view threshold
309.00
(+0.32%)Baseline: 308.00
311.08
(99.33%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_pop_benchmark_compile📈 view plot
🚷 view threshold
14.83 x 1e3
(-0.04%)Baseline: 14.84 x 1e3
14.99 x 1e3
(98.97%)
📈 view plot
🚷 view threshold
432.00
(-0.69%)Baseline: 435.00
439.35
(98.33%)
🐰 View full continuous benchmarking report in Bencher

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.00%. Comparing base (7de7032) to head (cc80c62).

Files with missing lines Patch % Lines
...ng/src/guppylang/std/collections/priority_queue.py 24.44% 34 Missing ⚠️
guppylang/src/guppylang/std/collections/queue.py 41.37% 17 Missing ⚠️
guppylang/src/guppylang/std/collections/stack.py 40.00% 15 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           mk/mutable-structs    #1796      +/-   ##
======================================================
- Coverage               93.02%   93.00%   -0.03%     
======================================================
  Files                     135      135              
  Lines                   13138    13145       +7     
======================================================
+ Hits                    12222    12225       +3     
- Misses                    916      920       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mark-koch mark-koch changed the title feat: Use mutable structs for std collections and make internals private feat!: Use mutable structs for std collections and make internals private Jun 2, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 2, 2026

Merging this PR will improve performance by 15.45%

⚡ 3 improved benchmarks
✅ 6 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_queue_push_pop_benchmark_compile 556.7 ms 467.3 ms +19.13%
test_queue_push_pop_benchmark 766.1 ms 672.4 ms +13.94%
test_queue_push_benchmark_compile 406.8 ms 358.8 ms +13.38%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mk/mutable-collections (cc80c62) with mk/mutable-structs (7de7032)

Open in CodSpeed

Base automatically changed from mk/mutable-structs to main June 8, 2026 12:48
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