I do catch the IndexError caused by the empty set problem.  I decided to log it, I hope that is appropriate.   
When you say cache it, do you mean I should physically make a static structure outside of the loop, or the act of creating the instance structure will create a situation where automatic caching will occur?