[Numpy-discussion] Porting strategy for py3k
ross smith
gaurdro@gmail....
Thu Apr 23 18:29:30 CDT 2009
On Thu, Apr 23, 2009 at 15:39, Robert Kern <robert.kern@gmail.com> wrote:
> On Thu, Apr 23, 2009 at 09:52, David Cournapeau <cournape@gmail.com>
> wrote:
> > On Thu, Apr 23, 2009 at 11:20 PM, Pauli Virtanen <pav@iki.fi> wrote:
> >> Thu, 23 Apr 2009 22:38:21 +0900, David Cournapeau kirjoitti:
> >> [clip]
> >>> I looked more in detail on what would be needed to port numpy to
> >>> py3k. In particular, I was interested at the possible strategies to
> keep
> >>> one single codebase for both python 2.x and python 3.x. The first step
> >>> is to remove all py3k warnings reported by python 2.6. A couple of
> >>> recurrent problems
> >>> - reduce is removed in py3k
> >>> - print is removed
> >>
> >> Print is not removed, just changed to a function. So,
> >>
> >> print("foo")
> >
> > Yes, as reduce, they are still available, but not as builtins anymore.
> > But replacing print is not as easy as reduce. Things like print
> > "yoyo", a do not work, for example.
>
> Doesn't the 2to3 tool do this conversion for you?
It does for Print at least.
conditional compiling for C would work. I could see extending it to the
python code as well. I don't know how feasible this is, but have a script
that runs at installation and cuts out blocks of code that aren't compatible
with the version it's being installed on. for example, run the script on a
file like below, and keep only what is useable by the version installed.
import foo
###py2x.begin
import py2xbar.py
###py2x.end
###py3k.begin
import py3kbar.py
###py3k.end
-just my .02
-Ross
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
> -- Umberto Eco
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090423/4522e556/attachment.html
More information about the Numpy-discussion
mailing list