Merge pull request #3503 from Glandos/patch-2

Don't try to hash value if enum is empty
This commit is contained in:
Hugo 2018-12-26 13:32:18 +02:00 committed by GitHub
commit 14b1321c42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,7 +29,10 @@ class TagInfo(namedtuple("_TagInfo", "value name type length enum")):
cls, value, name, type, length, enum or {})
def cvt_enum(self, value):
return self.enum.get(value, value)
# Using get will call hash(value), which can be expensive
# for some types (e.g. Fraction). Since self.enum is rarely
# used, it's usually better to test it first.
return self.enum.get(value, value) if self.enum else value
def lookup(tag):