Python Pandas global vs passed variable
large_dict = {
'blah1': {'also': 1},
'blah2': {'big': 1}
};
def do_something(k):
for key,val in large_dict[k].iteritems();
print "%s - %s" % (key,val)
do_something('blah1')
do_something('blah2')
As you can see large_dict is being accessed from the global namespace.
- is there any advantage of passing in large_dict into do_something as an argument or just access it as a global variable?
- Related question said local variable is faster but what about memory differences for global vs function argument esp if larg_dict is large (in Perl, we would pass in a reference, not a whole dict)?