space_packet_parser
space_packet_parser copied to clipboard
Add a Parseable Protocol and parse method
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 toSequenceContainerandParameterwith 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...)
- (Note that this is actually the same call signature as
- Moved
ParsedDataIteminto thextcedefmodule as it is now needed for theparse()method. Also had to reimport into theparsermodule for backwards compatibility. - Added a
ParseableProtocol, 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