Note that you only pay the cost once per function call in your first case and 
not every time you access it inside the function. When x is inside the function 
it's type is known so everything there is fast. This is usually called a 
"function barrier" where you shield away your performance critical part from a 
type instability by putting it inside a function like this. Upon calling the 
function the type will be dynamically looked up but will then stay constant 
inside the function.

Reply via email to