This sort of thing is also handled well by a dict.  If you allocate the dict on init it will also save time.