Skip to main content
`Ctrl`+`K`
scipy.

# LowLevelCallable

class scipy.LowLevelCallable(function, user_data=None, signature=None)

  Low-level callback function.

  Some functions in SciPy take as arguments callback functions, which can either be python callables or low-level compiled functions. Using compiled callback functions can improve performance somewhat by avoiding wrapping data in Python objects.

  Such low-level functions in SciPy are wrapped in `LowLevelCallable` objects, which can be constructed from function pointers obtained from ctypes, cffi, Cython, or contained in Python PyCapsule objects.

  See also

  Functions accepting low-level callables:

  `scipy.integrate.quad`, `scipy.ndimage.generic_filter`, `scipy.ndimage.generic_filter1d`, `scipy.ndimage.geometric_transform`

  Usage examples:

  Extending scipy.ndimage in C, Faster integration using low-level callback functions

  Parameters:
    function{PyCapsule, ctypes function pointer, cffi function pointer}

      Low-level callback function.

    user_data{PyCapsule, ctypes void pointer, cffi void pointer}

      User data to pass on to the callback function.

    signature str, optional

      Signature of the function. If omitted, determined from function, if possible.

  Notes

  The argument `function` can be one of:

  - PyCapsule, whose name contains the C function signature

  - ctypes function pointer

  - cffi function pointer

  The signature of the low-level callback must match one of those expected by the routine it is passed to.

  If constructing low-level functions from a PyCapsule, the name of the capsule must be the corresponding signature, in the format:

      return_type (arg1_type, arg2_type, ...)

  For example:

      "void (double)"
      "double (double, int *, void *)"

  The context of a PyCapsule passed in as `function` is used as `user_data`, if an explicit value for `user_data` was not given.

  Attributes:
    function

      Callback function given.

    user_data

      User data given.

    signature

      Signature of the function.

  Methods

  `from_cython`(module, name[, user_data, signature]) | Create a low-level callback function from an exported Cython function.