I have slowly been converting some Python source to Cython. I'm pretty conservative in what changes I make, mostly sprinkling a few "cdef", "float" and "int" declarations around the pyx file. Still, conservative or not, it's enough to choke pylint. Rather than have to maintain a pure Python version of my code, it would be nice if pylint had a flag or if there was a "cylint" tool available. A few Google and PyPi searches failed to reveal anything. Is there something out there? Thanks, Skip
Am 12.09.14 17:52, schrieb Skip Montanaro:
I have slowly been converting some Python source to Cython. I'm pretty conservative in what changes I make, mostly sprinkling a few "cdef", "float" and "int" declarations around the pyx file. Still, conservative or not, it's enough to choke pylint. Rather than have to maintain a pure Python version of my code, it would be nice if pylint had a flag or if there was a "cylint" tool available.
You should try pure Python mode: http://docs.cython.org/src/tutorial/pure.html This allows you to keep your code valid, pure python and put all the Cython related stuff into decorators. Works pretty well. There might be few places were it does not work; for example, wrapping C libraries. But you could put these parts in small, extra files and could still check most of your code. I would be interested in your experiences with this. So let me know how it works if you try. Mike
A few Google and PyPi searches failed to reveal anything. Is there something out there?
Thanks,
Skip
_______________________________________________ code-quality mailing list code-quality@python.org https://mail.python.org/mailman/listinfo/code-quality
On Fri, Sep 12, 2014 at 12:25 PM, Mike Müller
You should try pure Python mode: http://docs.cython.org/src/tutorial/pure.html
So I leave my Python code as-is in somemodule.py and put the Cython declarations in somemodule.pyd. My make targets are map pyd files to so instead of pyx to so? (I don't use setup.py. I'm very old school.) Thx, Skip
Skip Montanaro schrieb am 12.09.2014 um 20:38:
On Fri, Sep 12, 2014 at 12:25 PM, Mike Müller wrote:
You should try pure Python mode: http://docs.cython.org/src/tutorial/pure.html
So I leave my Python code as-is in somemodule.py and put the Cython declarations in somemodule.pyd. My make targets are map pyd files to so instead of pyx to so?
".py" -> ".so" instead of ".pyx" -> ".so", yes. Latest Cython also has a "cythonize" script that can compile and build modules ("cythonize -i pkg/module.py" -> "pkg/module.so").
(I don't use setup.py. I'm very old school.)
That sounds a bit old-school, yes. To compile a Cython module, it can be as simple as this: """ from distutils.core import setup from Cython.Build import cythonize setup( ext_modules=cythonize('hello.py'), ) """ And it will avoid rebuilding if it's up-to-date, just like make does. (This is getting quite off-topic for this list, though...) Stefan
participants (3)
-
Mike Müller
-
Skip Montanaro
-
Stefan Behnel