Nice suggestions, and I like your API. Using the context manager to look like loops is nifty.
Thanks, the one problem with that is that you have to use dumpy.wrap if you ever create a function that uses loops and then you want to call it inside another loop. But I don't see any way around that.
Along the same vein, could we just move entirely to Einstein summation? It seems like your solution is 90% there.
I assume there is a good reason why you didn't
Well, Einstein summation is good, but it only does multiplication and sums. (Or, more generally, some scalar operation and some scalar reduction.) I want a notation that works for ANY type of operation, including non-scalar ones, and that's what DumPy does. So I'd argue it moves further than Einstein summation.
I knew there was a reason lol
There's einx which allows expressing most tensor operations using einsum-like notation: https://github.com/fferflo/einx (Disclaimer: I'm the author). Dumpy and einx actually seem similar to me in that they both use axis names to represent for-loops/vectorization over some simpler, underlying operation.
Great follow-up to "I don't like NumPy", it's always better to show by example how things could be better. Minor nit, it would be nice if the different code samples at the end were displayed side-by-side somehow. Also wondering if the assert x.ndim == 1 in softmax_dumpy somehow meaningful? The other examples, including "DumPy (alternate)", don't have that check.
At one point, I actually had some (LLM-generated) boxes where you could click to switch between the different implementations for the same problem. But in the end I didn't like how it looked, so I switched to simple expandy-boxes. Design is hard...
There's no magical significance to the assert x.ndim==1 check. I think I just wanted to demonstrate that the softmax code was "simple" and didn't have to think about high dimensions. I think I'll just remove that, thanks.
Nice suggestions, and I like your API. Using the context manager to look like loops is nifty.
Thanks, the one problem with that is that you have to use
dumpy.wrap
if you ever create a function that uses loops and then you want to call it inside another loop. But I don't see any way around that.