If python has reasonable collections libraries available (surely it does!), you can also switch that in-memory cache to be a balanced tree or other nicely optimized structure. That'd give n-log-n performance -- another factor-of-14 speedup for Student1's case. If that takes more than a couple more lines of code, I'd be really surprised.
|