News for hackers. Stuff that matters.
Re:A reasonably speedy Python ray tracer by Marazan on Saturday October 21, 2017 @01:58PM (#15522742)
I wrote a pure python (No Numpy) ray tracer as a learning exercise. Spoiler: it was slowwwwwwwwwww.

I converted to NumPy and it was just slow. I then went to array broadcasting (which required surprisingly few code changes due to NumPy being pretty awesome) and it became fast.

Re:A reasonably speedy Python ray tracer by tgb on Saturday October 21, 2017 @05:40PM (#15523756)
I'm familiar with the concept of broadcasting in Numpy, but I don't understand what it means in this context. Can someone explain?
Re:A reasonably speedy Python ray tracer by Marazan on Sunday October 22, 2017 @08:03AM (#15526409)
__s basically covers it but my initial switch from pure python to NumPy just involved changing my vector 'class' (just a tuple in reality) into NumPy arrays. Whilst the basic vector multiplications and additions became way faster the overhead of creating hundreds of tiny NumPy arrays was a killer.

So, just like in the original article instead of creating a single 1x3 array I created a Mx3 array where M represented as many rays as I could fit into memory at once (I have quite a weedy machine).

Due to how NumPy broadcasting exactly the same code for, say, subtracting the origin from a ray vector works to subtract that single origin vector for a multidimensional array of ray vectors.

Re:A reasonably speedy Python ray tracer by tgb on Sunday October 22, 2017 @10:07AM (#15526884)
I see now, thanks.
Re:A reasonably speedy Python ray tracer by __s on Saturday October 21, 2017 @09:54PM (#15524716)
Basically map https://docs.scipy.org/doc/numpy/user/basics.broadcasting.ht...

So OP would've converted from indexing numpy arrays in Python space