Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Suggestion] Use np.add.reduce instead of np.sum for slightly better performance #62

Open
@SaFE-APIOpt

Description


I noticed the following line:
s = np.sum(arr, axis=0)
If the code is performance-sensitive and does not rely on extra parameters like dtype, keepdims, or initial, you might consider replacing it with:
s = np.add.reduce(arr, axis=0)
np.sum is a high-level convenience function that internally calls np.add.reduce, but includes additional checks and wrappers. When you're performing simple summation along an axis, using np.add.reduce directly eliminates that overhead and can offer a slight speedup—especially in tight loops or large-scale computations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /