Skip to content

PERF: Drastically lower the overhead of __array_function__ #20790

@seberg

Description

@seberg

With the advent of the FASTCALL/Vectorcall protocol, it is now much easier to drastically lower the overhead currently associated with __array_function__ without the need to subtly change the semantics, e.g. by in-lining the "not a NumPy array" check.

Here is a branch starting a big chunk of this: main...seberg:faster-array-function

However, it is not polished or finished, it requires still the following:

  • Fixing like= for Python defined functions: They are broken, I have
    one possible approach, but it is just an "idea stage".
    (should not be hard, but needs a some thought)
  • Make sure the C entry-point looks and feel right, such as printing
    (I am not sure what is left to do here, maybe we can find prior art?)
  • Enable pickling (should be very easy)
  • Ensure PyPy compatibility if necessary
  • Change all warning stacklevel= to one lower (in wrapped functions).
    (simple, but a lot of churn)
  • General code cleanup

This may be a nice and very worthwhile project for someone interested in decreasing overheads and familiar with the Python C-API. I do not expect any of these things to be particularly hard nuts to crack, but they may be very hard to approach without a good working knowledge of the Python C-API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProjectPossible project, may require specific skills and long commitment

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions