Aug-18-2018, 05:37 AM
What length of the
Access to local variables via
using it in such context is still bad practice: 1) it pollutes local environment with
new variables 2) it makes code harder to analyze (it might be not easy to imagine what variables exists)
and finally...
var_keys
array?!griddata
should be fast, but you are trying to interpolate 8M points..!Access to local variables via
vars()
, locals()
is slower than direct access to them:> python -m timeit -s "dct={'val': None}" "dct['val']=23"
Output:0.0532 mu.sec per loop
> python -m timeit -s "val=0" "val=23"
Output:0.023 mu.sec per loop
> python -m timeit -s "val=0" "vars()['val']=23"
Output:0.325 mu.sec per loop
Even if we will not consider using vars()
/locals()
in terms of efficiency (it isn't efficient), using it in such context is still bad practice: 1) it pollutes local environment with
new variables 2) it makes code harder to analyze (it might be not easy to imagine what variables exists)
and finally...