-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand arg tuple handling to 12 and IntoPyNativeFn to 11 params #6101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,80 @@ into_func_args_from_tuple!((v1, T1), (v2, T2), (v3, T3)); | |
| into_func_args_from_tuple!((v1, T1), (v2, T2), (v3, T3), (v4, T4)); | ||
| into_func_args_from_tuple!((v1, T1), (v2, T2), (v3, T3), (v4, T4), (v5, T5)); | ||
| into_func_args_from_tuple!((v1, T1), (v2, T2), (v3, T3), (v4, T4), (v5, T5), (v6, T6)); | ||
| into_func_args_from_tuple!( | ||
| (v1, T1), | ||
| (v2, T2), | ||
| (v3, T3), | ||
| (v4, T4), | ||
| (v5, T5), | ||
| (v6, T6), | ||
| (v7, T7) | ||
| ); | ||
|
|
||
| into_func_args_from_tuple!( | ||
| (v1, T1), | ||
| (v2, T2), | ||
| (v3, T3), | ||
| (v4, T4), | ||
| (v5, T5), | ||
| (v6, T6), | ||
| (v7, T7), | ||
| (v8, T8) | ||
| ); | ||
|
|
||
| into_func_args_from_tuple!( | ||
| (v1, T1), | ||
| (v2, T2), | ||
| (v3, T3), | ||
| (v4, T4), | ||
| (v5, T5), | ||
| (v6, T6), | ||
| (v7, T7), | ||
| (v8, T8), | ||
| (v9, T9) | ||
| ); | ||
|
|
||
| into_func_args_from_tuple!( | ||
| (v1, T1), | ||
| (v2, T2), | ||
| (v3, T3), | ||
| (v4, T4), | ||
| (v5, T5), | ||
| (v6, T6), | ||
| (v7, T7), | ||
| (v8, T8), | ||
| (v9, T9), | ||
| (v10, T10) | ||
| ); | ||
|
|
||
| into_func_args_from_tuple!( | ||
| (v1, T1), | ||
| (v2, T2), | ||
| (v3, T3), | ||
| (v4, T4), | ||
| (v5, T5), | ||
| (v6, T6), | ||
| (v7, T7), | ||
| (v8, T8), | ||
| (v9, T9), | ||
| (v10, T10), | ||
| (v11, T11) | ||
| ); | ||
|
|
||
| into_func_args_from_tuple!( | ||
| (v1, T1), | ||
| (v2, T2), | ||
| (v3, T3), | ||
| (v4, T4), | ||
| (v5, T5), | ||
| (v6, T6), | ||
| (v7, T7), | ||
| (v8, T8), | ||
| (v9, T9), | ||
| (v10, T10), | ||
| (v11, T11), | ||
| (v12, T12) | ||
| ); | ||
|
|
||
| /// The `FuncArgs` struct is one of the most used structs then creating | ||
| /// a rust function that can be called from python. It holds both positional | ||
|
|
@@ -578,8 +652,8 @@ macro_rules! tuple_from_py_func_args { | |
| }; | ||
| } | ||
|
|
||
| // Implement `FromArgs` for up to 7-tuples, allowing built-in functions to bind | ||
| // up to 7 top-level parameters (note that `PosArgs`, `KwArgs`, nested tuples, etc. | ||
| // Implement `FromArgs` for up to 12-tuples, allowing built-in functions to bind | ||
| // up to 12 top-level parameters (note that `PosArgs`, `KwArgs`, nested tuples, etc. | ||
| // count as 1, so this should actually be more than enough). | ||
|
Comment on lines
+655
to
657
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainDoc note updated to 12-tuples — align all generators accordingly The doc now claims support up to 12. builtin.rs must match (currently missing 12), or the doc will be misleading for #[pymethod]/#[pyfunction] authors hitting 12 parameters. Would you like me to open a follow-up to extend both modules to 16 or 20 and add a small compile test to keep them in lockstep? 🏁 Script executed: #!/bin/bash
set -e
echo "=== Snippet around tuple support in vm/src/function/argument.rs ==="
sed -n '640,700p' vm/src/function/argument.rs || echo "Failed to read argument.rs snippet"
echo
echo "=== Locating builtin.rs ==="
builtin_file=$(fd --type f builtin.rs | head -n1)
if [ -z "$builtin_file" ]; then
echo "builtin.rs not found"
exit 1
else
echo "Found builtin.rs at: $builtin_file"
fi
echo
echo "=== First 200 lines of builtin.rs ==="
sed -n '1,200p' "$builtin_file" || echo "Failed to read builtin.rs snippet"Length of output: 9310 🏁 Script executed: #!/bin/bash
set -e
echo "=== Searching for invocation of into_py_native_fn_tuple! in vm/src/function/builtin.rs ==="
rg -n "into_py_native_fn_tuple!" vm/src/function/builtin.rs || echo "No invocations found"Length of output: 833 🏁 Script executed: #!/bin/bash
set -e
echo "=== Snippet of into_py_native_fn_tuple! invocations in builtin.rs ==="
sed -n '180,300p' vm/src/function/builtin.rs || echo "Failed to read snippet"Length of output: 2440 builtin.rs tuple support is out of sync with the “12-tuples” doc note The docs in • In into_py_native_fn_tuple!(
(v1, T1), …, (v11, T11), (v12, T12)
);• Add a small compile-test (e.g., bind a 12-argument dummy fn) to both modules to catch any future drift. 🤖 Prompt for AI Agents |
||
| tuple_from_py_func_args!(A); | ||
| tuple_from_py_func_args!(A, B); | ||
|
|
@@ -589,3 +663,7 @@ tuple_from_py_func_args!(A, B, C, D, E); | |
| tuple_from_py_func_args!(A, B, C, D, E, F); | ||
| tuple_from_py_func_args!(A, B, C, D, E, F, G); | ||
| tuple_from_py_func_args!(A, B, C, D, E, F, G, H); | ||
| tuple_from_py_func_args!(A, B, C, D, E, F, G, H, I); | ||
| tuple_from_py_func_args!(A, B, C, D, E, F, G, H, I, J); | ||
| tuple_from_py_func_args!(A, B, C, D, E, F, G, H, I, J, K); | ||
| tuple_from_py_func_args!(A, B, C, D, E, F, G, H, I, J, K, L); | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -215,6 +215,56 @@ into_py_native_fn_tuple!( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v7, T7) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| into_py_native_fn_tuple!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v1, T1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v2, T2), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v3, T3), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v4, T4), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v5, T5), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v6, T6), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v7, T7), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v8, T8) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| into_py_native_fn_tuple!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v1, T1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v2, T2), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v3, T3), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v4, T4), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v5, T5), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v6, T6), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v7, T7), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v8, T8), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v9, T9) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| into_py_native_fn_tuple!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v1, T1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v2, T2), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v3, T3), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v4, T4), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v5, T5), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v6, T6), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v7, T7), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v8, T8), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v9, T9), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v10, T10) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| into_py_native_fn_tuple!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v1, T1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v2, T2), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v3, T3), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v4, T4), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v5, T5), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v6, T6), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v7, T7), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v8, T8), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v9, T9), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v10, T10), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (v11, T11) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+218
to
+266
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainSanity-check macro parity across files with a quick repo scan Let’s verify there’s a 12-arity wrapper here and both 12-arity binding and IntoFuncArgs in argument.rs. 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Check builtin.rs for 12-arity wrapper:"
rg -nP -C2 $'into_py_native_fn_tuple!\\s*\\(\\s*(?s).*\\(v12,\\s*T12\\)' vm/src/function/builtin.rs || {
echo "Missing v12 block in builtin.rs"; exit 1;
}
echo "Check argument.rs for 12-arity FromArgs tuple:"
rg -n $'tuple_from_py_func_args!\\(A, B, C, D, E, F, G, H, I, J, K, L\\);' vm/src/function/argument.rs
echo "Check argument.rs for 12-arity IntoFuncArgs-from-tuple:"
rg -nP -C2 $'into_func_args_from_tuple!\\s*\\(\\s*(?s).*\\(v12,\\s*T12\\)' vm/src/function/argument.rsLength of output: 283 Add missing 12-arity support • In into_py_native_fn_tuple!(
(v1, T1),
(v2, T2),
(v3, T3),
(v4, T4),
(v5, T5),
(v6, T6),
(v7, T7),
(v8, T8),
(v9, T9),
(v10, T10),
(v11, T11),
(v12, T12)
);• In
These additions are required to maintain parity and enable functions with 12 native parameters. 🤖 Prompt for AI Agents🛠️ Refactor suggestion Extend wrappers to 12-arity to match argument.rs and avoid immediate ceiling at 11 argument.rs now supports binding up to 12 top-level parameters; builtin.rs tops out at 11, so a #[pymethod]/#[pyfunction] with 12 parameters will still fail to compile due to missing IntoPyNativeFn coverage. Aligning both to 12 prevents a new hard limit right away and matches the updated doc note in argument.rs. Apply this diff to add the missing 12-arity tuple: into_py_native_fn_tuple!(
(v1, T1),
(v2, T2),
(v3, T3),
(v4, T4),
(v5, T5),
(v6, T6),
(v7, T7),
(v8, T8),
(v9, T9),
(v10, T10),
(v11, T11)
);
+into_py_native_fn_tuple!(
+ (v1, T1),
+ (v2, T2),
+ (v3, T3),
+ (v4, T4),
+ (v5, T5),
+ (v6, T6),
+ (v7, T7),
+ (v8, T8),
+ (v9, T9),
+ (v10, T10),
+ (v11, T11),
+ (v12, T12)
+);Follow-up:
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[cfg(test)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mod tests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use super::*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Arity 12 IntoFuncArgs tuple coverage looks correct; ensure builtin.rs is kept in sync
This tops out IntoFuncArgs at 12; builtin.rs currently only wraps up to 11. Please add a 12-arity wrapper there to prevent a mismatch.
I included a diff for builtin.rs in my other comment.
🤖 Prompt for AI Agents