Skip to content

Conversation

@kumarUjjawal
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

The factorial function currently converts scalar inputs to arrays before processing. Adding a scalar fast path avoids this overhead and improves performance.

What changes are included in this PR?

  1. Refactored invoke_with_args to use match statement for handling both scalar and array inputs
  2. Inlined array processing logic, removing make_scalar_function usage.
Type Before After Speedup
factorial_scalar 244 ns 102 ns 2.4x

Are these changes tested?

Yes, covered by existing SLT tests:

  • scalar.slt lines 461-477
  • math.slt line 797

Are there any user-facing changes?

@github-actions github-actions bot added the functions Changes to functions implementation label Jan 23, 2026
6402373705728000,
121645100408832000,
2432902008176640000,
]; // if return type changes, this constant needs to be updated accordingly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to keep this comment

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

Labels

functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants