4 ms·
Big fan of using Cython for things where you need significant performance optimization.
by EternalData 9y ago
Big fan of using Cython for things where you need significant performance optimization.
- sandGorgon 9y agohow do you develop in cython - doesnt the compile, load and test cycle break your flow inside IDE ?
- dr_zoidberg 9y agoYou can either compile-before-run (as you would any compiled language), our you can leverage Cythons compile-on-import mechanism. Which does exactly the same, but you don't have to think about having to compile. Compile time is usually down to a few seconds (or less), so it's not really a burden.
- sandGorgon 9y agohey - thanks for this. what do you personally use ? It is more interesting to learn from someone who has been using it for a while. I'm especially concerned about IDE support, debuggability and testability.
- dr_zoidberg 9y agoFor IDE support, I'm totally in love with PyCharm and been using it for years, first community and then I upgraded to Pro for Cython support. PyCharm Pro has syntax highlighting and does inspections (linting) on Cython code, so it's a wonderful tool, totally worth its price. Can't really recommend any other IDE because I haven't used another one for over 4 years, though a friend uses (loves) Sublime Text and has high praise for it too. It has Cython syntax support, but there's really no linter for Cython -- what's more, you may have to turn off warnings if you're using a Python linter because it'll complain about cdefs and such. As for the day to day use, I don't do that much Cython really, ocassionally to speed things up. I start from a Python function, then make a .pyx (or bunch of .pyxes) files and replicate what's needed. Compile, load both versions (Py and Cy) and compare outputs and speed from IPython or with benchmark scripts. I did use a lot the Cython functionality to create the HTML view of the source source at the beggnining, though you get the hang of what transpiles well with time and use it less and less. Still, sometimes it's useful.
- sandGorgon 9y agowhy did you not choose to use numba ? because the performance in a lot of cases is faster, and most importantly the IDE/debugging integration is seamless.
- dom0 9y agoNot a big fan of Cython here... https://hn.algolia.com/?query=dom0%20cython&sort=byPopularity&prefix&page=0&dateRange=all&type=comment https://hn.algolia.com/?query=dom0%20cython&sort=byPopularit...