default value's instance unless it's absolutely necessary.
raise IOError(ENOENT, 'No translation file found for domain', domain)
key = os.path.abspath(mofile)
# TBD: do we need to worry about the file pointer getting collected?
- t = _translations.setdefault(key, class_(open(mofile, 'rb')))
+ # Avoid opening, reading, and parsing the .mo file after it's been done
+ # once.
+ t = _translations.get(key)
+ if t is None:
+ t = _translations.setdefault(key, class_(open(mofile, 'rb')))
return t