Skip to content

Speed up PowExpr._evaluate via the C-level API - #1278

Open
Zeroto521 wants to merge 4 commits into
scipopt:masterfrom
Zeroto521:p3d-pow-cpow
Open

Zeroto521 wants to merge 4 commits into
scipopt:masterfrom
Zeroto521:p3d-pow-cpow

Conversation

@Zeroto521

@Zeroto521 Zeroto521 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Replace the Python ** in PowExpr._evaluate with the C pow() function and keep the Python semantics for raising zero to a negative power.

PowExpr._evaluate over (x + x + 1) ** -2.0 with a fixed solution, n = 5_000_000, min of 3 rounds:

implementation time
before (Python **) ~0.90s
after (c_pow + guard) ~0.65s

~25-30% speedup.

Evaluate PowExpr values with C's pow function and raise ZeroDivisionError for zero raised to a negative exponent. Add regression coverage for negative exponents and division by zero.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Zeroto521 Zeroto521 changed the title Speed up \PowExpr._evaluate\ via the C-level API Speed up PowExpr._evaluate via the C-level API Oct 19, 2026
Rename the evaluated operand from `val` to `base` in `PowExpr._evaluate` for clearer naming.
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.08%. Comparing base (9547994) to head (ed1156b).
⚠️ Report is 29 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1278      +/-   ##
==========================================
+ Coverage   57.91%   58.08%   +0.17%     
==========================================
  Files          26       27       +1     
  Lines        5807     6029     +222     
==========================================
+ Hits         3363     3502     +139     
- Misses       2444     2527      +83     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants