Hi Everyone, Some time ago, I posted a series of changes [1] to switch from SWIG to PyBind for our Python wrappers. I'd like to know what people think about this move at a high level. Do we want to make this change?
These are the main benefits I have identified: * PyBind11 can be redistributed with gem5, which means that we have full control of the version used. This avoid a large number of hard-to-debug SWIG issues we have seen in the past. * PyBind11 doesn't rely on a custom C++ parser, instead it relies on wrappers being explicitly declared in C++. The leads to slightly more boiler-plate code in manually created wrappers, but doesn't doesn't increase the overall code size. A big benefit is that this avoids strange compilation errors when SWIG doesn't understand modern language features. * Unlike SWIG, there is no risk that the wrapper code incorporates incorrect type casts (this has happened on numerous occasions in the past) since these will result in compile-time errors. * It fixes a compiler error we have been experiencing with some some SWIG versions when compiled using clang 3.8. * It becomes easier to export new methods to Python. In the simplest case, a place holder method can be declared in Python and decorated with @cxxMethod, which inherits the doc string from the place holder. The new wrappers have the following known issues: * Global events can't be memory managed correctly. This was the case in SWIG as well. * GCC 5.x seems to generate C++ ODR warnings in some cases when compiling the fast binary. See Pierre's comment on [2]. * It changes the way custom methods are exported to Python (the export_methods class method is disappearing), which breaks the current API. Do we consider the ODR warnings to be serious enough to block this if we think the change is a good idea? I have been trying to reproduce them using PyBind's test suite, but without success so far. Cheers, Andreas [1] https://gem5-review.googlesource.com/#/q/topic:pybind11+(status:open+OR+status:merged) [2] https://gem5-review.googlesource.com/#/c/2231/ IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. _______________________________________________ gem5-dev mailing list [email protected] http://m5sim.org/mailman/listinfo/gem5-dev
