On Mon, Aug 15, 2016 at 2:29 AM, <
fchap...@gmail.com> wrote:
> Hello,
>
> I have a question about imports in cython and python2/python3 compatibility.
>
> I am working on sagemath, with a large number of cython files.
>
> To ensure compatibility with both py2 and py3, is it necessary in cython
> files (just as in python files) to add
>
> from __future__ import absolute_import
>
> and to change the imports to the python3 syntax ?
By default, Cython assumes code is Python 2 but produces extensions
compatible with Python 3. Somewhat in jest, Cython has been called the
easiest way to port Python 2 code to Python 3--just compile it.
Cython does support "from __future__ import absolute_import" and if
you use this, you do have to change the imports to be Python 3
compatible.
> And what about the cimports ?
Exactly the same as imports.
> Is there any tool available to do this cleanly for me ? Something like
> futurize ?
Not that I know of, but for just fixing [c]imports a simple script
probably wouldn't be too hard to put together.