CircArgs edited a comment on issue #3464: URL: https://github.com/apache/iceberg/issues/3464#issuecomment-962364884
@jun-he thanks a lot for the explanation. I have a good idea of what you're describing I think. I definitely dont want to seem like I'm making an argument for types to be based on dataclasses or anything I just used them to get the more auto implemented methods for free for my example (and I still had to make the decorator to account for the special null behavior I saw in the legacy python implementation). It still seems to me that the fixed types fit well into the model I tried to describe though. What do you think about something like (also in the updated gist https://gist.github.com/CircArgs/a4571332d72888e3773f66bd180bb0e0): ```python @dataclass class _FixedTypeBase(Type): '''base fixed type for behavior of a fixed type e.g. FixedType[16]''' value: bytes def __repr__(self): return f'FixedType{self._length}(value={self.value})' def __str__(self): return repr(self) class FixedTypes: implemented: Dict[int, _FixedTypeBase]=dict() def __getitem__(self, length: int): if length in self.implemented: return self.implemented[length] else: class _FixedType(_FixedTypeBase): _length = length self.implemented[length]=_FixedType return _FixedType FixedType=FixedTypes() #usage # FixedType[16](string.encode(...)) FixedType[16]==FixedType[16] ``` I went with this pattern in case there's a need for types of arbitrary length, but if they were to be just 8, 16, 32, 64, ... then I could see why they might just be written out fully without this. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
