Skip to content

Provide explicit function signatures for numba #45

Closed

Description

@stestoll

On my system, numba is crashing Python when @njit-decorated functions are called. The problem disappears when explicit function signatures are provided to @njit. Should we provides these?

Activity

  1. mtessmer commented on Jan 6, 2023

    @mtessmer
    Collaborator

    Like Julia, numba can take advantage of multiple dispatch. This means I can njit function without specifying the type and it will work on several different types.

    @njit
    def myfunc(inp):
        return inp
       
    print(myfunc(10))    # -> 10
    print(myfunc('10'))  # -> '10' 

    But once you specify a signature you can only use types of that signature.

    @njit(''i8(i8)')
    def myfunc(inp):
        return inp
       
    print(myfunc(10))    # -> 10
    print(myfunc('10'))  # -> TypeError: No matching definition for argument type(s) unicode_type

    This is useful because it allows njit functions to be more dynamic. If I specify signatures, then I would need to specify all possible signatures if I want to maintain this functionality. In your specific case, using multiple signatures may not fix the crashing problem, so it may not even be worth it.

  2. mtessmer commented on Apr 20, 2023

    @mtessmer
    Collaborator

    This issue appears to have been resolved with numba/numba#8852

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions