Begin a batch of drawing commands. They will only be displayed when batchEnd() is called (these calls can be nested). This means the drawing does not refresh the screen after every command is hence faster.
w=gfx.Window(); w:batchBegin() function r() return math.random()*300; end for i=1,1000 do w:line(r(),r(),r(),r()); end w:batchEnd()