I have a very hot segment of code in a large project. I've extracted the relevant segment and a toy example to illustrate it. The project involves an unavoidable combinatorial explosion related to graph theory, so there's no limit to how fast is 'good enough' -- but rather, each significant speed...