Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-11652

Document that stl_bind.h pybind11 wrapping is not recommended

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: To Do
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: None
    • Story Points:
      1

      Description

      While wrapping some some jointcal C++ to write python tests for it, I discovered pybind11's stl_bind.h opaque wrappers. This did the job for me, but it was not recommended by our pybind11 gurus, for various reasons. We don't mention it in the stl section of the dev guide, although we do have two related mentions of wrapping stl types in the pybind11 style guide:

      https://developer.lsst.io/coding/pybind11_style_guide.html#default-automatic-conversions-shall-be-used-for-all-stl-containers
      https://developer.lsst.io/coding/pybind11_style_guide.html#where-copying-of-stl-containers-is-undesirable-an-ndarray-type-should-be-used-instead

      Please add a note to the dev guide stl section about why not to use the stl_bind-style opaque wrappers, since that's the obvious place to look when wondering about wrapping stl objects. It might be worth adding an example that returns the object via a C++ lambda (if we don't have such an example already), e.g.:

          cls.def("getMappingIndices", [](PhotometryMappingBase const &self) {
              std::vector<unsigned> indices(0);
              self.getMappingIndices(indices);
              return indices;
          });
      

        Attachments

          Issue Links

            Activity

            Parejkoj John Parejko created issue -
            Parejkoj John Parejko made changes -
            Field Original Value New Value
            Assignee John Parejko [ parejkoj ]
            Parejkoj John Parejko made changes -
            Risk Score 0
            Parejkoj John Parejko made changes -
            Assignee John Parejko [ parejkoj ] Russell Owen [ rowen ]
            rowen Russell Owen made changes -
            Assignee Russell Owen [ rowen ]
            tjenness Tim Jenness made changes -
            Remote Link This issue links to "Page (Confluence)" [ 32308 ]
            rowen Russell Owen made changes -
            Watchers Jim Bosch, John Parejko, John Swinbank, Kian-Tat Lim, Pim Schellart [X], Russell Owen [ Jim Bosch, John Parejko, John Swinbank, Kian-Tat Lim, Pim Schellart [X], Russell Owen ] Jim Bosch, John Parejko, John Swinbank, Kian-Tat Lim [ Jim Bosch, John Parejko, John Swinbank, Kian-Tat Lim ]
            Parejkoj John Parejko made changes -
            Link This issue relates to DM-38634 [ DM-38634 ]

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              Parejkoj John Parejko
              Watchers:
              Jim Bosch, John Parejko, John Swinbank, Kian-Tat Lim
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:

                  Jenkins

                  No builds found.