-
Notifications
You must be signed in to change notification settings - Fork 163
Description
Is your feature request related to a problem? Please describe.
I am generating code to call from a Python script. When I use the Python backend, SymForce's generated code is in the hot path of my script.
Describe the solution you'd like
My end goal is a compiled CPython extension module containing functions that take/return NumPy arrays, but do all the SymPy generated computations internally in machine code.
One possible design
I know from experience (https://github.com/jpreiss/mlpfile) that pybind11 is good at generating NumPy wrappers for functions that take/return Eigen types. However, it requires writing some boilerplate code. I believe that SymPy's codegen function already has all the information needed to generate the boilerplate. Therefore, one could achieve my end goal by reusing the existing C++/Eigen codegen and adding an extra codegen layer for the pybind11 boilerplate.
Describe alternatives you've considered
Generating code for other binding tools (like SWIG) or even raw CPython C code would also give the desired speedup, but implementing the backend would probably be more difficult. To my knowledge, pybind11 is the most convenient for wrapping code that uses Eigen.