Skip to content

Commit 8c723d2

Browse files
committed
ENH: NPV: Parallelize native hot-path
This leads to the following improvements on the `time_broadcast` benchmark with dimension 100x100x100: * raw Python: 197 ms * numba only: 4.08 ms * numba + prange 0.3 ms
1 parent 2d08783 commit 8c723d2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

numpy_financial/_financial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,10 @@ def irr(values, *, guess=None, tol=1e-12, maxiter=100, raise_exceptions=False):
852852
return np.nan
853853

854854

855-
@nb.njit
855+
@nb.njit(parallel=True)
856856
def _npv_native(rates, values, out, zero, one):
857-
for i in range(rates.shape[0]):
858-
for j in range(values.shape[0]):
857+
for i in nb.prange(rates.shape[0]):
858+
for j in nb.prange(values.shape[0]):
859859
acc = zero
860860
for t in range(values.shape[1]):
861861
acc += values[j, t] / ((one + rates[i]) ** t)

0 commit comments

Comments
 (0)