Re:Faster Natural Language Processing in Python
by imh on Tuesday June 12, 2018 @04:52PM
(#17297863)
I love seeing Cython usage. Python is cool, but as a scientific language, its slowness gets in the way sometimes. Particularly when you have control flow with funny shapes, so it is hard to just apply multipurpose vectorized functions. In my experience, NLP often has funny shapes like that.
Cython is a wonderful escape hatch to grab performance, and I'd love to see it used more casually in the data science world.
Re:Faster Natural Language Processing in Python
by dr_zoidberg on Wednesday June 13, 2018 @10:12AM
(#17303194)
Cython is compiled C that uses CPythons objects. If you can distill your algorithm to a full C(ython) implementation, you get CPython objects + C code, which is then compiled with the (appropriate version of the) system compiler.
Cython is a wonderful escape hatch to grab performance, and I'd love to see it used more casually in the data science world.
So for example, from this little Cython code:
You get the following C code: That compiles and becomes part of a C-extension that you can load with "import module" from within Python.