Skip to content

Increase parameter limit for trait beyond 7 argumentsIntoPyNativeFn #6098

@topcoco

Description

@topcoco

Summary

The current IntoPyNativeFn trait implementation has a hard limit of 7 parameters (excluding &VirtualMachine), which prevents defining Python methods with more arguments using the #[pymethod] attribute.

Problem

When trying to define a Python method with more than 7 parameters, the compiler fails with:
error[E0277]: the trait bound is not satisfiedfn(..., ..., i32, f32, i32, i32, i32, i32, i32, i32, i32, ...) -> ... {...::orb}: IntoPyNativeFn<...>

Example

This function fails to compile due to having 11 parameters:

#[pymethod]  
fn orb(  
    query_path: String,  
    source_path: String,  
    nfeatures: i32,  
    scale_factor: f32,  
    nlevels: i32,  
    edge_threshold: i32,  
    first_level: i32,  
    wta_k: i32,  
    score_type: i32,  
    patch_size: i32,  
    fast_threshold: i32,  
    vm: &VirtualMachine,  
) -> PyResult<PyObjectRef> { ... }  
While this function with 7 parameters compiles successfully:

#[pymethod]  
fn sift(  
    query_path: String,  
    source_path: String,  
    nfeatures: i32,  
    n_octave_layers: i32,  
    contrast_threshold: f64,  
    edge_threshold: f64,  
    sigma: f64,  
    vm: &VirtualMachine  
) -> PyResult<PyObjectRef> { ... }




Extend the macro to support more parameter combinations, perhaps up to 15-20 parameters. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions