From 0b8b3e679a1381d56924b05855e0bcb3512a5dd4 Mon Sep 17 00:00:00 2001 From: Glandos Date: Sat, 22 Dec 2018 15:29:31 +0100 Subject: [PATCH] Add code comment --- src/PIL/TiffTags.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PIL/TiffTags.py b/src/PIL/TiffTags.py index c47a88fe7..0264a6066 100644 --- a/src/PIL/TiffTags.py +++ b/src/PIL/TiffTags.py @@ -29,6 +29,9 @@ class TagInfo(namedtuple("_TagInfo", "value name type length enum")): cls, value, name, type, length, enum or {}) def cvt_enum(self, 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