Details
-
Type:
Improvement
-
Status: Done
-
Resolution: Done
-
Fix Version/s: None
-
Component/s: afw
-
Labels:
-
Story Points:6
-
Epic Link:
-
Sprint:DRP S17-3, DRP S17-4
-
Team:Data Release Production
Description
The way BaseRecord is wrapped in pybind11 needs some work:
- get and __getitem__ should be wrapped the way they were with SWIG, which is simpler code than was used, and looks identical for the two methods (though that code uses $action so there are subtle differences). Better yet, make the methods identical if possible.
- The wrappings should probably use C++ method _get, which needs to be added in the pybind11 wrapper file, rather than the specializations that use suffixes.
- The C++ wrapper defines _getitem_ for each data type and the code is radically different than for _get_ + suffix. It would be nice if the differences could be eliminated.
Similar issues apply to several other afw::table classes.
Attachments
Issue Links
- blocks
-
DM-9100 Merge pybind11 branches to master
- Done
- is blocked by
-
DM-8805 Metaclass for wrapped-template ABCs and class extension decorators
- Done
-
DM-9099 Begin cleanup of pybind11 branch
- Done
- relates to
-
DM-9018 Investigate downcasting of Table and Record types in pybind11
- Done
-
DM-8674 Wrap testSourceTable with pybind11
- Done
-
DM-6782 afw table string keyword access is much slower than asKey access
- Invalid
(1 relates to)
While get and __getitem__ have a similar structure in the SWIG code, the $action command is different.
__getitem__ calls the C++ operator[] method and returns a reference, while getX returns a value, and specifies the type that it expects. For convenience (and to make the code more pythonic) get was implemented in SWIG so that the user doesn't need to specify the type. However, there are numerous tests and places in the code that use getX methods, so when I wrapped afw::table I had to keep that design. This causes the python code to look slightly different since pybind11 doesn't have a $action command.
So completing this ticket would require changing the API for afw::table, which is probably not a good idea until after the pybind11 port is successful.