3 ms·
I don't think that's what I was looking for. That talks about dispatching generic functions at compile time. > you still have polymorphism that can’t be effic
by admax88q 6y ago
I don't think that's what I was looking for. That talks about dispatching generic functions at compile time.
> you still have polymorphism that can’t be efficiently monomorphized without an exponential space penalty.
Wouldn't it be linear at each call site only by the number of types that actually reach that call site? Plus you don't have to cache _all_ types at the call site, only the most frequent ones.
In Java and JS for instance, dynamic dispatch is JITed away at hot spots, and can be un-jitted later to reclaim space if the spot is no longer hot.
I generally don't care if a dynamic dispatch is slow if I'm only calling it a few times, but in a tight loop I want it to be inlined as much as possible.