type: cache CompoundType._member()

Parsing the member designator and walking the members is relatively
expensive and can be in the hot path when iterating over lots of
objects.
This commit is contained in:
Omar Sandoval 2018-05-18 23:18:40 -07:00
parent 0089014fed
commit 2c0b63eda3

View File

@ -14,6 +14,7 @@ help(Type).
from collections import OrderedDict
import enum
import functools
import math
import numbers
import re
@ -542,6 +543,7 @@ class CompoundType(Type):
"""
return list(self._members_by_name)
@functools.lru_cache()
def _member(self, member: str) -> Tuple[Type, int]:
designator = parse_member_designator(member)
type_: Type = self