I did not start from np.searchsorted.
The idea came from a broader question I had been exploring in my own infrastructure work:
Has the system already paid for information that we are about to compute again?
In my CoreFoundry project, one recurring principle was simple: before adding more hardware or parallelism, first remove work that never needed to happen.
That same question eventually led me to np.searchsorted.
Reusing information that already exists#
np.searchsorted finds insertion positions in a sorted array.
We explore how to speed up binary search by batching independent searches with NumPy’s vectorized operations. We then reformulate the algorithm so all searches progress together with only $O(1)$ additional memory, port it to C++, and achieve up to a 25× speedup over NumPy 2.4’s implementation.
Many real-world shortest path problems include constraints that classic algorithms don’t directly handle. NetworkX provides robust, optimized implementations of algorithms like Dijkstra’s, Bellman-Ford, and A*. But what if your problem doesn’t fit the classic shortest path formulation?