Hi Christopher, Christopher Howard <christop...@librehacker.com> skribis:
> Hi, I'm doing a project with SDR involving a lot of number crunching, > as SDR usually does, with Guile 3.0 embedded in a C application. Of > course, the idea is to have the C functions handle the low-level > number crunching. But it some places it is difficult to get around > performance hits from required scheme conversions, e.g.: scheme > bytevector -> scheme pointer -> C pointer. Of course, working on > reducing those, but wondering... > > (1) Do I have any options for unsafe conversions, e.g., some guile > library out there which would convert bytevector to C pointer without > typechecking? Nope. Unfortunately, ‘bytevector->pointer’ is currently relatively expensive because it allocates memory: https://lists.gnu.org/archive/html/guile-devel/2019-11/msg00019.html Now, you could write a C function that takes a bytevector and then uses ‘SCM_BYTEVECTOR_CONTENTS’ on it. That’d allow you to sidestep ‘bytevector->pointer’ altogether. > (2) Is there anything I can do as far as inlining those core conversion > functions that might be useful? I don’t think so. However, note that Guile 3.0 should be good at number crunching: it can unbox floats and integers, and there’s whole-module inlining too, so all in all, it should work well and allow crossing the C/Scheme border. Worth a try! Ludo’.