PYTHON-346 - Type lookup and caching improvements.