C compilers can do that with whole-program optimization:
1. Clone the function taking the callback, and set that parameter constant so the value of the callback is known.
2. Change the indirect calls to direct calls.
3. Inline the new direct calls.
Of course, the library has to be statically linked, but that's not a problem for scientific users.
Remember, if you optimize something yourself, just make friends with a compiler engineer and get them to add it!
C compilers can do that with whole-program optimization:
1. Clone the function taking the callback, and set that parameter constant so the value of the callback is known.
2. Change the indirect calls to direct calls.
3. Inline the new direct calls.
Of course, the library has to be statically linked, but that's not a problem for scientific users.
Remember, if you optimize something yourself, just make friends with a compiler engineer and get them to add it!