ExplainaBoard icon indicating copy to clipboard operation
ExplainaBoard copied to clipboard

Replacing structured types with datatype

Open odashi opened this issue 2 years ago • 1 comments

Several functions use NumPy's structured arrays. I thought it is better to replace them to dataclasses for several reasons:

  • It is basically not informative to users to know what members are contained in the array since the array does not provide static type information (i.e., users can't comprehend the behavior by seeing the function signatures). Unfortunately we couldn't expect that structured arrays are supported by a mypy-friendly manner in the near future: https://github.com/numpy/numpy/issues/7370#issuecomment-908308757
  • Manipulating structured arrays with heterogeneous data is usually much expensive than manipulating usual objects. Enforcing memory alignment can mitigate this problem, but it requires to constrain the length of string fields, which may be not suitable for the current implementation.

RFC: @neubig @pfliu-nlp

odashi avatar Aug 15 '22 21:08 odashi

Sorry I realize I didn't comment on this yet, but I agree with this general direction and I think we're moving in this direction already!

neubig avatar Oct 10 '22 15:10 neubig