Speeding up Python with Nim
robert-mcdermott.gitlab.io
robert-mcdermott.gitlab.io
Really cool! It seems to be comparable and perhaps even faster than cython!
I happened to be in an Ipython shell and didn't see anyway to do this with nim, but you can probably get a good approximate of the speedup with nim in Ipython/Jupyter by doing a quick:
[1] %load_ext Cython
[2] %%cython ``` cpdef long cyfib(int n): if n <= 2: return 1 else: return cyfib(n - 1) + cyfib(n - 2) ```
[3] start=time.time(); x = cyfib(47); end=time.time(); print(x); print(end-start)
2971215073 5.558561325073242
Nice choice of 47! I had to change the cython function's return time to long to prevent overflow. Something you don't need to do in nim
import nimpy; let datetime = pyImport("datetime"); echo datetime.datetime.now(); let pysys = pyImport("sys") ; echo pysys.version;
It is really cool.
By the way, the nimpy looks cool. Thanks for sharing.