Re:Making Cython as easy as Python
by versteegen on Tuesday September 22, 2015 @04:43AM
(#10257405)
As dagw said, if your inner loops aren't inside a .pyx file, then Cython can do little to help. Even if there are, if it involves lots of fiddling with data structures like dicts and lists, or making use of dynamic or high level features of Python like generators or classes or list comprehensions, then Cython would provide only a small speed increase (say, 20%), because almost all the running time will be spent inside the Python runtime. To get the biggest speed ups out of Cython you need to write C-like code with type annotations. E.g. "for x in range(...):" loops.
The calls to itertools won't be sped up significantly. However if then you loop over the results of a call to itertools and do something to each element, then that loop might end up being much faster.
it may be worth checking out cytoolz
Yup. Cytoolz. Some notes on performance of Cytoolz:
http://matthewrocklin.com/blog/work/2014/05/01/Introducing-C...
Re:Making Cython as easy as Python
by python_que on Wednesday September 23, 2015 @05:58AM
(#10264153)
great thanks both for the tip.
My question is if I would still get a considerable speed-up if I rewrite some of my code in Cython, given my reliance on itertools?