Piexif
Piexif copied to clipboard
Better struct module usage
This improves usage of standard struct module. unpack_from function doesn't require extra copying as well as doesn't require data length match.
Also there was a several places where sequence of unpack calls can be replaced with single call.
- tag = struct.unpack(self.endian_mark + "H",
- self.tiftag[pointer: pointer+2])[0]
- value_type = struct.unpack(self.endian_mark + "H",
- self.tiftag[pointer + 2: pointer + 4])[0]
- value_num = struct.unpack(self.endian_mark + "L",
- self.tiftag[pointer + 4: pointer + 8]
- )[0]
+ tag, value_type, value_num = unpack_from(
+ self.endian_mark + "HHL", self.tiftag, pointer)