Created
October 6, 2015 20:06
-
-
Save andyfaff/3af1f722b0032edef6e2 to your computer and use it in GitHub Desktop.
profiling asteval initiation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> %load_ext line_profiler | |
>>> from lmfit import Parameters,Parameter | |
>>> from lmfit.asteval import Interpreter | |
>>> %lprun -f Interpreter.__init__ -f Parameters.__init__ Parameters() | |
Timer unit: 1e-06 s | |
Total time: 0.005639 s | |
File: /Users/anz/miniconda3/envs/dev3/lib/python3.4/site-packages/lmfit-0.9.1_17_g4a9b540-py3.4.egg/lmfit/asteval.py | |
Function: __init__ at line 72 | |
Line # Hits Time Per Hit % Time Line Contents | |
============================================================== | |
72 def __init__(self, symtable=None, writer=None, use_numpy=True): | |
73 1 3 3.0 0.1 self.writer = writer or stdout | |
74 | |
75 1 1 1.0 0.0 if symtable is None: | |
76 1 2 2.0 0.0 symtable = {} | |
77 1 2 2.0 0.0 self.symtable = symtable | |
78 1 1 1.0 0.0 self._interrupt = None | |
79 1 2 2.0 0.0 self.error = [] | |
80 1 2 2.0 0.0 self.error_msg = None | |
81 1 2 2.0 0.0 self.expr = None | |
82 1 1 1.0 0.0 self.retval = None | |
83 1 2 2.0 0.0 self.lineno = 0 | |
84 1 2 2.0 0.0 self.use_numpy = HAS_NUMPY and use_numpy | |
85 | |
86 1 2 2.0 0.0 symtable['print'] = self._printer | |
87 89 117 1.3 2.1 for sym in FROM_PY: | |
88 88 121 1.4 2.1 if sym in __builtins__: | |
89 88 137 1.6 2.4 symtable[sym] = __builtins__[sym] | |
90 | |
91 2 4 2.0 0.1 for symname, obj in LOCALFUNCS.items(): | |
92 1 1 1.0 0.0 symtable[symname] = obj | |
93 | |
94 38 52 1.4 0.9 for sym in FROM_MATH: | |
95 37 67 1.8 1.2 if hasattr(math, sym): | |
96 37 62 1.7 1.1 symtable[sym] = getattr(math, sym) | |
97 | |
98 1 1 1.0 0.0 if self.use_numpy: | |
99 392 513 1.3 9.1 for sym in FROM_NUMPY: | |
100 391 698 1.8 12.4 if hasattr(numpy, sym): | |
101 391 737 1.9 13.1 symtable[sym] = getattr(numpy, sym) | |
102 9 14 1.6 0.2 for name, sym in NUMPY_RENAMES.items(): | |
103 8 14 1.8 0.2 if hasattr(numpy, sym): | |
104 8 13 1.6 0.2 symtable[name] = getattr(numpy, sym) | |
105 | |
106 1 2 2.0 0.0 self.node_handlers = dict(((node, getattr(self, "on_%s" % node)) | |
107 1 80 80.0 1.4 for node in self.supported_nodes)) | |
108 | |
109 # to rationalize try/except try/finally for Python2.6 through Python3.3 | |
110 1 2 2.0 0.0 self.node_handlers['tryexcept'] = self.node_handlers['try'] | |
111 1 1 1.0 0.0 self.node_handlers['tryfinally'] = self.node_handlers['try'] | |
112 | |
113 1 1 1.0 0.0 self.no_deepcopy = [] | |
114 480 963 2.0 17.1 for key, val in symtable.items(): | |
115 479 988 2.1 17.5 if (callable(val) or 'numpy.lib.index_tricks' in repr(val)): | |
116 467 1029 2.2 18.2 self.no_deepcopy.append(key) | |
Total time: 0.010819 s | |
File: /Users/anz/miniconda3/envs/dev3/lib/python3.4/site-packages/lmfit-0.9.1_17_g4a9b540-py3.4.egg/lmfit/parameter.py | |
Function: __init__ at line 38 | |
Line # Hits Time Per Hit % Time Line Contents | |
============================================================== | |
38 def __init__(self, asteval=None, *args, **kwds): | |
39 1 54 54.0 0.5 super(Parameters, self).__init__(self) | |
40 1 1 1.0 0.0 self._asteval = asteval | |
41 1 1 1.0 0.0 if asteval is None: | |
42 1 10737 10737.0 99.2 self._asteval = Interpreter() | |
43 1 26 26.0 0.2 self.update(*args, **kwds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment