space_packet_parser icon indicating copy to clipboard operation
space_packet_parser copied to clipboard

Add a Parseable Protocol and parse method

Open greglucas opened this issue 1 year ago • 0 comments

This enables the same call structure when parsing the data fields and easier pass-through. It is also faster in the hot-loop than using isinstance() to get the specific path to go down.

This builds upon the other two performance PRs as I'm whittling things down here and the calling type definitions change, so it was easier to test on top of everything. I can remove them if that would be helpful, but for review you can just look at the final commit here: 98491cec9df52926849aae7930c44b084812ec50

Changes:

  • Added a parse() method to SequenceContainer and Parameter with the same call signature.
    • (Note that this is actually the same call signature as parse_value(), but with different return types. I'm wondering if there is actually a way to structure these all the same...)
  • Moved ParsedDataItem into the xtcedef module as it is now needed for the parse() method. Also had to reimport into the parser module for backwards compatibility.
  • Added a Parseable Protocol, not completely necessary, but seems like something nice to define.
  • Changed to using dataclasses for the data structures. These automatically bring along the AttrComparable-like stuff and this cleaned up some of the init/repr things IMO. Again, not totally necessary, but I think it'd be nice to start removing some of the boilerplate code if we can.

Checklist

  • [x] Changes are fully implemented without dangling issues or TODO items
  • [n/a] Deprecated/superseded code is removed or marked with deprecation warning
  • [n/a] Current dependencies have been properly specified and old dependencies removed
  • [n/a] New code/functionality has accompanying tests and any old tests have been updated to match any new assumptions
  • [ ] The changelog.md has been updated

greglucas avatar Jul 31 '24 15:07 greglucas