Michel Pelletier <pelletier.michel@gmail.com> writes: > ... > I agree it makes sense to have more use cases before making deeper > changes. I only work with expanded forms, but need to call wait() to > pre-expand the object to avoid multiple expansions in functions that can > take the same object in multiple parameters.
Hmm. I agree that the wait() call is a bit ugly, but there are at least two things that seem worth looking into before we go so far as inventing type-support infrastructure:
2. If the problem is primarily with passing the same object to multiple parameters of a function, couldn't you detect and optimize that within the function? It would be messier than just blindly applying DatumGetWhatever() to each parameter position; but with a bit of thought I bet you could create some support logic that would hide most of the mess.
Ah that's a great idea, and it works beautifully! Now I can do an efficient triangle count without even needing a function, see below expand_matrix is only called once:
What a wonderful Christmas present to me, thank you Tom!
That pretty much resolves my main issues. I'm still in an exploratory phase but I think this gets me pretty far. Is this something that has to wait for 18 to be released? Also do you need any further testing or code reviewing from me?