Skip to content

support slurping arguments next to keyword arguments - #168

Open
singhharsh1708 wants to merge 1 commit into
JuliaDynamics:masterfrom
singhharsh1708:varargs-with-kwargs
Open

singhharsh1708 wants to merge 1 commit into
JuliaDynamics:masterfrom
singhharsh1708:varargs-with-kwargs

Conversation

@singhharsh1708

@singhharsh1708 singhharsh1708 commented Sep 8, 2026 •

Copy link
Copy Markdown

Fixes #135.

get_slots concatenates the arguments and the keyword arguments into one positional list, so f(a...; k=1) became f(a..., k) and julia rejected the non-final .... Slurping arguments are now passed the object they collect rather than splatted a second time, there and in the wrapper that forwards to it. That object is what the state machine stores, so f(a; k...) also stops failing on a Base.Pairs to Tuple conversion.

Tests cover f(a...; k...), f(a; k...), f(; k...) and f(a...; k=1). Green on 1.10, 1.11 and 1.12 apart from jet, which fails the same way on master here.

Supersedes #138, which de-splatted in place and so lost the user's own a... from the wrapper. #169 and #170 are neighbouring forms, still broken and untouched.

`get_slots` builds its inference function from the arguments and the keyword
arguments concatenated into one positional list, so anything after a slurping
argument left the `...` in a non-final position. Pass slurping arguments the
object they collect instead of splatting them a second time, which is also what
the state machine stores for them.

Fixes JuliaDynamics#135
@github-actions

Copy link
Copy Markdown

Benchmark Results (Julia v1)

Time benchmarks
master 991406f... master / 991406f...
hardcoded types/BigInt/Channels csize=0 0.165 ± 0.0013 ms 0.165 ± 0.0017 ms 0.999 ± 0.013
hardcoded types/BigInt/Channels csize=1 0.169 ± 0.0018 ms 0.171 ± 0.0015 ms 0.991 ± 0.014
hardcoded types/BigInt/Channels csize=100 22 ± 0.51 μs 22.1 ± 0.48 μs 0.997 ± 0.032
hardcoded types/BigInt/Channels csize=20 28.9 ± 0.52 μs 29 ± 0.49 μs 0.999 ± 0.025
hardcoded types/BigInt/Closure 5.4 ± 0.14 μs 5.4 ± 0.13 μs 1 ± 0.035
hardcoded types/BigInt/Closure optimized 3.6 ± 0.11 μs 3.57 ± 0.1 μs 1.01 ± 0.042
hardcoded types/BigInt/Closure statemachine 3.59 ± 0.26 μs 3.6 ± 0.38 μs 0.997 ± 0.13
hardcoded types/BigInt/Direct 3.63 ± 0.12 μs 3.54 ± 0.1 μs 1.03 ± 0.045
hardcoded types/BigInt/Iteration protocol 3.61 ± 0.11 μs 3.56 ± 0.09 μs 1.01 ± 0.04
hardcoded types/BigInt/ResumableFunctions 3.57 ± 0.1 μs 3.57 ± 0.11 μs 1 ± 0.042
hardcoded types/BigInt/Task scheduling 0.0331 ± 0.11 ms 0.034 ± 0.11 ms 0.974 ± 4.5
hardcoded types/Int64/Channels csize=0 0.156 ± 0.0015 ms 0.157 ± 0.0012 ms 0.992 ± 0.012
hardcoded types/Int64/Channels csize=1 0.155 ± 0.0018 ms 0.158 ± 0.0015 ms 0.98 ± 0.014
hardcoded types/Int64/Channels csize=100 17.9 ± 0.29 μs 18 ± 0.26 μs 0.995 ± 0.022
hardcoded types/Int64/Channels csize=20 24.3 ± 0.29 μs 24.6 ± 0.3 μs 0.99 ± 0.017
hardcoded types/Int64/Closure 2.25 ± 0.011 μs 2.32 ± 0.011 μs 0.97 ± 0.0066
hardcoded types/Int64/Closure optimized 0.05 ± 0 μs 0.05 ± 0 μs 1 ± 0
hardcoded types/Int64/Closure statemachine 0.05 ± 0 μs 0.05 ± 0 μs 1 ± 0
hardcoded types/Int64/Direct 0.05 ± 0.001 μs 0.05 ± 0.009 μs 1 ± 0.18
hardcoded types/Int64/Iteration protocol 0.06 ± 0.01 μs 0.06 ± 0.01 μs 1 ± 0.24
hardcoded types/Int64/ResumableFunctions 0.05 ± 0 μs 0.05 ± 0 μs 1 ± 0
hardcoded types/Int64/Task scheduling 29.4 ± 1.1e+02 μs 30.3 ± 1.1e+02 μs 0.973 ± 5.1
time_to_load 0.0373 ± 0.00064 s 0.0371 ± 0.00068 s 1.01 ± 0.025
Memory benchmarks
master 991406f... master / 991406f...
hardcoded types/BigInt/Channels csize=0 0.302 k allocs: 7.7 kB 0.302 k allocs: 7.7 kB 1
hardcoded types/BigInt/Channels csize=1 0.302 k allocs: 7.71 kB 0.302 k allocs: 7.71 kB 1
hardcoded types/BigInt/Channels csize=100 0.305 k allocs: 9.24 kB 0.305 k allocs: 9.24 kB 1
hardcoded types/BigInt/Channels csize=20 0.305 k allocs: 9.24 kB 0.305 k allocs: 9.24 kB 1
hardcoded types/BigInt/Closure 0.192 k allocs: 5.23 kB 0.192 k allocs: 5.23 kB 1
hardcoded types/BigInt/Closure optimized 0.19 k allocs: 5.2 kB 0.19 k allocs: 5.2 kB 1
hardcoded types/BigInt/Closure statemachine 0.19 k allocs: 5.2 kB 0.19 k allocs: 5.2 kB 1
hardcoded types/BigInt/Direct 0.188 k allocs: 5.14 kB 0.188 k allocs: 5.14 kB 1
hardcoded types/BigInt/Iteration protocol 0.19 k allocs: 5.2 kB 0.19 k allocs: 5.2 kB 1
hardcoded types/BigInt/ResumableFunctions 0.19 k allocs: 5.2 kB 0.19 k allocs: 5.2 kB 1
hardcoded types/BigInt/Task scheduling 0.197 k allocs: 5.85 kB 0.197 k allocs: 5.85 kB 1
hardcoded types/Int64/Channels csize=0 0.097 k allocs: 2.27 kB 0.097 k allocs: 2.27 kB 1
hardcoded types/Int64/Channels csize=1 19 allocs: 1.06 kB 19 allocs: 1.06 kB 1
hardcoded types/Int64/Channels csize=100 22 allocs: 2.59 kB 22 allocs: 2.59 kB 1
hardcoded types/Int64/Channels csize=20 22 allocs: 2.59 kB 22 allocs: 2.59 kB 1
hardcoded types/Int64/Closure 0.082 k allocs: 1.28 kB 0.082 k allocs: 1.28 kB 1
hardcoded types/Int64/Closure optimized 0 allocs: 0 B 0 allocs: 0 B
hardcoded types/Int64/Closure statemachine 0 allocs: 0 B 0 allocs: 0 B
hardcoded types/Int64/Direct 0 allocs: 0 B 0 allocs: 0 B
hardcoded types/Int64/Iteration protocol 0 allocs: 0 B 0 allocs: 0 B
hardcoded types/Int64/ResumableFunctions 0 allocs: 0 B 0 allocs: 0 B
hardcoded types/Int64/Task scheduling 0.085 k allocs: 1.88 kB 0.085 k allocs: 1.88 kB 1
time_to_load 0.201 k allocs: 11.8 kB 0.201 k allocs: 11.8 kB 1

This branch has not been deployed

No deployments
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.

resumable function with splatted args does not work in the presence of keyword args, e.g. @resumable function f(a...; kw=1)

1 participant