I was working on a similar function for one of my projects and realised the improvements I made there were also applicable here.
This is basically a full rewrite of the function but there is no change functionally (all the tests still pass).
This provides a speedup of 70X for a single date, and a 2X speedup for 10 million dates, scaling between those two numbers for other vector sizes! Importantly the changes also use 2.5-3X less memory.
I was working on a similar function for one of my projects and realised the improvements I made there were also applicable here.
This is basically a full rewrite of the function but there is no change functionally (all the tests still pass).
This provides a speedup of 70X for a single date, and a 2X speedup for 10 million dates, scaling between those two numbers for other vector sizes! Importantly the changes also use 2.5-3X less memory.