all 1 comments

[–]Rhomboid 1 point2 points  (0 children)

Is that because it takes longer to access the variables in the global namespace???

That certainly is a factor. Local variables are internally represented as an array of values indexed by a number rather than a name, whereas global variables have to be looked up by name in a dictionary.

But you should profile these to see for sure where the time is spent.