r/tinycode • u/Yeknom • Jan 09 '13
Ray tracer in 140 SLOC of python with picture
I have be playing with raytracing for a while now and wanted to write something that was simple to understand but produced a cool effect. There is defiantly many more features that could be added, like reflections and multiple light sources, but I wanted to stay as minimalistic possible.
Source: http://pastebin.com/F8f5GHJZ
Image: http://imgur.com/prPGk
70
Upvotes
4
u/Twirrim Jan 10 '13
Is there a particular reason why functions are quicker than classes? Naively I assumed that mostly under the surface it would execute / optimize mostly the same?
thought I'd randomly chuck these through pypy 1.9, 26s->11s for the standard code python vs pypy, then 16s->11s for your function based code.