#26052·scipy

ENH: special: further work on ufunc delegation and documentation

Author: steppiCreated Aug 28, 2026Updated Oct 1, 2026
Labelsenhancementscipy.specialDocumentationarray types

#26032 added UFunc wrappers which preserve ufunc behavior. This helps us avoid the breaking change discussed in #19252 that would be introduced by turning ufuncs into regular functions to support delegation to alternative backends. I have more work, completed, initiated, and planned in this direction, but to make reviews easier I am going to break it up into a series of smaller targeted PRs. I catalogued some of the follow-ups I plan to make in #26032 and am listing them in this issue so none fall through the cracks, as suggested by @j-bowhay here.

  • Add support for generalized universal functions to the delegation in scipy/special/_support_alternative_backends.py. https://github.com/scipy/scipy/pull/26093
  • Extend delegation to all ufunc and ufunc-like special functions in scipy.special
  • Implement lazy loading to avoid using exec to dynamically generate all of the special function wrappers upon import of scipy.special.
  • Move docstrings out of C++ files into a Python file, and store them together with argument names to pass to the dynamic wrapper generator.
  • Document the kwargs parameter of ufunc wrappers.
  • Replace ufunc docstring appended at the end of ufuncs, (which will get lost when we move to regular Python docstrings) with an appended section describing ufunc wrappers.
  • Add source links to ufunc wrappers that point to somewhere useful. Perhaps to a single page that explains how ufuncs are implemented, and then gives a list with links to all the scalar kernel sources.