Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a
numba
version of the "better" IRR implementation. It doesn't do anything other than provide the code for a new benchmark, so this PR can live until all the things are in place.Note that in order for the
numba
version to work, you need to convert thecfs
array to anumpy
array. If you pass in thenumpy
array to the original "better" version, you actually get a decent speedup (1.75x) -- I think that should be reflected in these benchmarks (either switch to that version or show both). On my machine, the three Newton/"better" runs benchmark as follows:In short, the
numba
version is 26x faster than the original "better" and 15x faster than thenumpy
-fed "better".A few other things to note:
numpy
andtimetit
imports are necessary, cashflow arrays hardcoded in code makes it less readable) so as not to accidentally break things.numba
version on my own environment using Python 3.10.6 and made sure the result was the same as the "better" version. The fact that the benchmarks don't have a clear way to install an environment for someone to run is problematic IMO and should be addressed.I'd like to open an issue or discussion to discuss improvements to these benchmarks. I know you started an issue regarding more realistic array sizes in #3 but that's only one aspect I'd like to address. Let me know if I should open a new one or if there is a specific place you want to have that discussion.