according to https://scipy-lectures.org/advanced/opt ... x.html#id5
there are some tricks to speedup python code.
When i do the following in my default python i get this:
Code: Select all
In[2]: import timeit
In[3]: import numpy as np
In[4]: a = np.arange(100)
In[5]: %timeit a**2
1.76 µs ± 58.2 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In[6]: def b(x):
...: bb = x ** 2
...: return(bb)
...:
In[7]: %timeit b(a)
2.26 µs ± 49.1 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
but in FreeCAD it don't work
Code: Select all
>>> import numpy as np
>>> import timeit
>>> a = np.arange(100)
>>> %timeit a ** 2
File "<input>", line 1
%timeit a ** 2
^
SyntaxError: invalid syntax
OS: OS X El Capitan (10.11)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17175 (Git)
Build type: Release
Branch: master
Hash: 507c40669d48ae4732268324cd0140c80cf68222
Python version: 3.7.3
Qt version: 5.9.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Netherlands (en_NL)
If this is not possible
what i'm doing right now looks like this
Code: Select all
import numpy as np
import scipy
def func1():
do something
def func2():
do func 2
def slow_func():
slow func what needs to speedup
if __name__ == "__main__":
a = func1()
b = func2(a)
# Here i want to do the timeit func
timeit... ?