local draw = draw - for what?

Sometimes i see code like this

local draw = draw
local surface = surface
local cam = cam
local math = math
local team = team

What’s the purpose of it? I’ve missed something?

Once some code has been compiled to bytecode, it doesn’t have the references to the global functions it calls immediately, it has to perform a lookup at runtime.

It’s also used in Lua modules because the module(…) function changes what global variables you can index unless you use package.seeall.

So, that is for perfomance? Ok, thanks for reply!