Live data from Hacker News

DumPy: NumPy except it's OK if you're dum

dynomight.net

41–50 of 62 posts

Re: DumPy: NumPy except it's OK if you're dum

#41

Lots to like here but I'm not so sure about this: > In DumPy, every time you index an array or assign to a dp.Slot, it checks that all indices have been included. Not having to specify all indices makes for more generic implementations. Sure, the broadcasting rules could be simpler and more consistent, but in the meantime (implicit) broadcasting is what makes NumPy so powerful and flexible. Also I think straight up v…

Implicir means write once easy, debug, extend, read hard.

It also means that you don't have to reimplement the same things all over again when your dimensions change.

Re: DumPy: NumPy except it's OK if you're dum

#42

Lots to like here but I'm not so sure about this: > In DumPy, every time you index an array or assign to a dp.Slot, it checks that all indices have been included. Not having to specify all indices makes for more generic implementations. Sure, the broadcasting rules could be simpler and more consistent, but in the meantime (implicit) broadcasting is what makes NumPy so powerful and flexible. Also I think straight up v…

For solo works, the terseness might work, but usually only in short term. Code I wrote 6 months ago looks like someone else's code. For team work, I'd prefer to be explicit if possible. It saves both my teammates' time and my time (when I eventually forget my own code 6 months from now).

It's not (only) about terseness. It's about generality.

Re: DumPy: NumPy except it's OK if you're dum

#43

I think I'll just use Julia, since it has great libraries for doing matrix operations and mapping loops etc onto GPUs and handling indices etc. And if you need some Python library it's easily available using the fantastic PyCall library. This is a big improvement over numpy, but I don't see much of a compelling reason to go back to Python.

> I don't see much of a compelling reason to go back to Python.

Being able to use sane programming workflows is quite a compelling reason.

Re: DumPy: NumPy except it's OK if you're dum

#45

It seems like a neat idea. If it can just be layered on top of Jax pretty easily… I dunno, seems so simple it might actually get traction? I wish I could peek at the alternative universe where Numpy just didn’t include broadcasting. Broadcasting is a sort of ridiculous idea. Trying to multiply a NxM matrix by a 1x1 matrix… should return an error, not perform some other operation totally unrelated to matrix multiplica…

Broadcasting is an excellent idea. Implementations do have warts, but e.g. pytorch would be really painful without it.

Broadcasting is a sort of generalization of the idea of scalar-matrix product. You could make that less "ridiculous" by requiring a Hadamard product with a constant value matrix instead.

Re: DumPy: NumPy except it's OK if you're dum

#46

Lots to like here but I'm not so sure about this: > In DumPy, every time you index an array or assign to a dp.Slot, it checks that all indices have been included. Not having to specify all indices makes for more generic implementations. Sure, the broadcasting rules could be simpler and more consistent, but in the meantime (implicit) broadcasting is what makes NumPy so powerful and flexible. Also I think straight up v…

[deleted]

Re: DumPy: NumPy except it's OK if you're dum

#47
I don't think this is such a great solution. With regular numpy you can create functions that take arrays with arbitrary shapes. It is not easy, as the author explained in a prior post, but it is doable. But with loops this just doesn't work. The number of nested loops depends on the shape of the inputs.

My solution, very, very inelegant, was to focus on the scalar case, and ask Copilot to vectorize my code. I did that just the last two days. It is not all that easy. Copilot will give you something, but you still need to tweak it. In the end, I still had to write line by line the code, and make sure I understand what it is doing.

Re: DumPy: NumPy except it's OK if you're dum

#48

It seems like a neat idea. If it can just be layered on top of Jax pretty easily… I dunno, seems so simple it might actually get traction? I wish I could peek at the alternative universe where Numpy just didn’t include broadcasting. Broadcasting is a sort of ridiculous idea. Trying to multiply a NxM matrix by a 1x1 matrix… should return an error, not perform some other operation totally unrelated to matrix multiplica…

Broadcasting is an excellent idea. Implementations do have warts, but e.g. pytorch would be really painful without it. Broadcasting is a sort of generalization of the idea of scalar-matrix product. You could make that less "ridiculous" by requiring a Hadamard product with a constant value matrix instead.

Scalar-matrix multiplication doesn’t seem that weird; automatically converting a 1x1 matrix to a scalar is the weird seeming thing, IMO.

Re: DumPy: NumPy except it's OK if you're dum

#49

I think I'll just use Julia, since it has great libraries for doing matrix operations and mapping loops etc onto GPUs and handling indices etc. And if you need some Python library it's easily available using the fantastic PyCall library. This is a big improvement over numpy, but I don't see much of a compelling reason to go back to Python.

> I don't see much of a compelling reason to go back to Python. Being able to use sane programming workflows is quite a compelling reason.

what sane programming workflows do you find Julia lacking?

Re: DumPy: NumPy except it's OK if you're dum

#50

I think this sort of DSL construction is a perfect fit for languages with macros: Lisp, Nim, etc. I spend a lot of time on both so I might explore the possibilities. What should a higher-dimensional array indexing, looping, and broadcasting syntax even look like, if until now it's just been cludges? Is it just APL but with actual words?

hear me out: Julia.
Post reply on HN