Skip to content

feat: Support generic comptime functions#1630

Open
mark-koch wants to merge 1 commit intomainfrom
mk/generic-comptime
Open

feat: Support generic comptime functions#1630
mark-koch wants to merge 1 commit intomainfrom
mk/generic-comptime

Conversation

@mark-koch
Copy link
Copy Markdown
Collaborator

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

Closes #896

BREAKING CHANGE: TracedFunctionDef is no longer a CompilableDef, but now a CheckableGenericDef that returns a monomorphic TracedMonoFunctionDef after checking
BREAKING CHANGE: trace_function now requires the generic instantiation as an extra argument

@mark-koch mark-koch requested a review from a team as a code owner April 2, 2026 14:13
@mark-koch mark-koch requested a review from acl-cqc April 2, 2026 14:13
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

🐰 Bencher Report

Branchmk/generic-comptime
TestbedLinux
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
tests/benchmarks/test_big_array.py::test_big_array_check📈 view plot
🚷 view threshold
498,346.28 µs
(-38.39%)Baseline: 808,929.89 µs
849,376.38 µs
(58.67%)
tests/benchmarks/test_big_array.py::test_big_array_compile📈 view plot
🚷 view threshold
1,357,856.57 µs
(-13.27%)Baseline: 1,565,544.88 µs
1,643,822.13 µs
(82.60%)
tests/benchmarks/test_big_array.py::test_big_array_executable📈 view plot
🚷 view threshold
6,267,170.48 µs
(-10.07%)Baseline: 6,969,038.29 µs
7,317,490.20 µs
(85.65%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_check📈 view plot
🚷 view threshold
76,847.48 µs
(-22.15%)Baseline: 98,714.66 µs
103,650.39 µs
(74.14%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile📈 view plot
🚷 view threshold
142,670.06 µs
(-22.44%)Baseline: 183,939.09 µs
193,136.05 µs
(73.87%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_executable📈 view plot
🚷 view threshold
723,402.41 µs
(-33.61%)Baseline: 1,089,615.34 µs
1,144,096.11 µs
(63.23%)
tests/benchmarks/test_prelude.py::test_import_guppy📈 view plot
🚷 view threshold
34.76 µs
(-17.11%)Baseline: 41.94 µs
44.03 µs
(78.95%)
🐰 View full continuous benchmarking report in Bencher

@hugrbot
Copy link
Copy Markdown
Collaborator

hugrbot commented Apr 2, 2026

This PR contains breaking changes to the public Python API.
Please deprecate the old API instead (if possible), or mark the PR with a ! to indicate a breaking change.

Breaking changes summary
guppylang-internals/src/guppylang_internals/tracing/function.py:62: trace_function(node):
Positional parameter was moved
Details: position: from 4 to 5 (+1)

guppylang-internals/src/guppylang_internals/tracing/function.py:62: trace_function(generic_args):
Parameter was added as required

guppylang-internals/src/guppylang_internals/definition/traced.py:0: TracedFunctionDef.compile_outer:
Public object was removed

guppylang-internals/src/guppylang_internals/definition/traced.py:0: CompiledTracedFunctionDef.__init__(func_def):
Positional parameter was moved
Details: position: from 6 to 7 (+1)

guppylang-internals/src/guppylang_internals/definition/traced.py:0: CompiledTracedFunctionDef.__init__(generic_args):
Parameter was added as required


@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.01887% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.45%. Comparing base (bde8404) to head (df9ca44).

Files with missing lines Patch % Lines
...ernals/src/guppylang_internals/tracing/function.py 76.92% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1630      +/-   ##
==========================================
- Coverage   93.50%   93.45%   -0.06%     
==========================================
  Files         130      130              
  Lines       12397    12439      +42     
==========================================
+ Hits        11592    11625      +33     
- Misses        805      814       +9     

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

🐰 Bencher Report

Branchmk/generic-comptime
TestbedLinux
Click to view all benchmark results
Benchmarkhugr_bytesBenchmark Result
bytes x 1e3
(Result Δ%)
Upper Boundary
bytes x 1e3
(Limit %)
hugr_nodesBenchmark Result
nodes x 1e3
(Result Δ%)
Upper Boundary
nodes x 1e3
(Limit %)
tests/benchmarks/test_big_array.py::test_big_array_compile📈 view plot
🚷 view threshold
141.59 x 1e3
(0.00%)Baseline: 141.59 x 1e3
143.00 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
6.64 x 1e3
(0.00%)Baseline: 6.64 x 1e3
6.71 x 1e3
(99.01%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile📈 view plot
🚷 view threshold
25.96 x 1e3
(0.00%)Baseline: 25.96 x 1e3
26.22 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
1.07 x 1e3
(0.00%)Baseline: 1.07 x 1e3
1.08 x 1e3
(99.01%)
🐰 View full continuous benchmarking report in Bencher

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.

Support generic comptime functions

3 participants