----- Original Message ----- > From: "Jim Bosch" <tallji...@gmail.com> ... > - Add a __eq__/__ne__ overrides to the class of things you're > putting > in the list, with an implementation that compares C++ pointers, not > Python pointers. This is almost certainly much easier, but it's a > little less "complete" as a solution, in the sense that you'll still > be getting different Python objects back for the same C++ object (so > while "param2 == param1" will succeed, "param1 is param2" will still > fail).
This is very helpful! That's OK about "is" not working, I think (though true, a little odd.) Can I override __hash__ too, so set membership works correctly? Also do I need to override __ne__; I think not? For the record, here's what I did. Defined a comparison function: static bool params_equal(Param &left, Param &right) { return &left == &right; } and then in the exposer: Param_exposer.def("__eq__", ¶ms_equal); -- Gary Oberbrunner _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org https://mail.python.org/mailman/listinfo/cplusplus-sig