4 ms·
Without modifications it yields between 20 to 30% increase in performance. However Cythons strength is in the type annotations. With those it should get close t
by dr_zoidberg 11y ago
Without modifications it yields between 20 to 30% increase in performance. However Cythons strength is in the type annotations. With those it should get close to C speed.
- allendoerfer 11y agoI would love the Cython team to work on the performance without modifications. Maybe they could make use of the standardized type hints of Python 3.5. I could see myself compile with Cython here and there if the performance gains would be meaningful but I do not want to write Cython.
- dr_zoidberg 11y agoConsidering that Python 3 remains slower than Python 2 on many benchmarks, what you're suggesting would be an interesting feature for Cython/Python 3 -- "Compile your Python 3 code with Cython and get 100%* speedup (*on average)". However, as I understand, Py3's type hints are derived from a previously available module (which I think also worked with Py2). So why would they add compatibility for that now? Why not just write your own parser that reads types annotations and then outputs Cython-equivalent variables declartions? There are also some Cython specific types that you won't find, for example the functions can be either cdef or cpdef, depending if you plan to use them from C only, or C and Python. I still see value in learning Cython as a complement to Python, for the cases where you need to get "closer to the metal". It's not so much more, and it helps a lot in performance.
- dr_zoidberg 11y agoSo I can't edit my previous response anymore, but going over Ian Ozsvalds talks, I found this particular snippet (about 1 minute), in which he describes ShedSkin as pretty much what you want ;) The link: https://www.youtube.com/watch?v=4LlCqlMJr3E&t=18m50s https://www.youtube.com/watch?v=4LlCqlMJr3E&t=18m50s The whole talk is valuable, of course, but it might not be your thing if you're not into numerical coding.