My question is about nvals = nvals(graph) in that function above, the object is flattened and then rexpanded, even after the object was expanded and returned by wait() [1] into a r/w pointer.
...
mxm calls expand_matrix three times for each of the three arguments. Ideally I'd like the already expanded rw pointer from wait() to be honored by mxm so that it doesn't re-expand the object three times but, like set_element, not at all.
My bad, sorry for the long confusing email, I figured out that I was calling the wrong macro when getting my matrix datum and inadvertently expanding RO pointers as well, I've fixed that issue, and everything is working great! No extra expansions and my support functions are working well, I need to go through a few more places in the API to add more support but otherwise the fixes Tom has put into plpgsql have worked perfectly and the library now appears to be behaving optimally! I can get down to doing some benchmarks and head-to-head with the C and Python bindings to compare against.
Thanks for your help Tom, I'm looking forward to the changes being released soon! In the meanwhile I'll keep a locally patched version for ongoing testing purposes.