Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MOE Python 3.4-compatible #415

Open
suntzu86 opened this issue Oct 28, 2014 · 5 comments
Open

Make MOE Python 3.4-compatible #415

suntzu86 opened this issue Oct 28, 2014 · 5 comments

Comments

@suntzu86
Copy link
Contributor

Python 2.7 is pretty much at the end of it's support life-span (and way past the end of development). We dev'd for 2.7 originally b/c of external constraints in our first runtime environments. Those are now gone.

The python-suggested basic workflow for doing this conversion:
https://docs.python.org/3/whatsnew/3.0.html#porting-to-python-3-0
more detailed:
https://docs.python.org/3/howto/pyporting.html

This ticket is for tracking what needs to get changed. This is not a complete list but hopefully covers the big ones. Hopefully the "-3" option from the prev link covers these:

  • Paste library not supported in Python 3.x: I believe we use paste (paster?) as part of pyramid. They have a workaround: http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/whatsnew-1.3.html
    Note that pyramid itself is compatible with 3.4.
  • language changes that i know are relevant to us:
    • print is now a statement (wow thank god)
    • integer division returns a float. Use a // b to get the old C-style, truncating division.
    • xrange is gone, range now does what xrange used to do. to get old range behavior, coerce xrange output to a list.
    • dict.iterkeys, iteritems, etc. are gone. dict.key, etc. now return "itemview" which is more similar to an iterator.
    • zip returns an iterator (instead of a list)
    • new metaclass syntax
    • total redefine of how unicode vs binary/byte data is handled; i don't think this applies to us.
      ** https://docs.python.org/2/library/2to3.html hopefully fixes many (all?) of these issues automagically

something cool:

  • function annotations: http://legacy.python.org/dev/peps/pep-3107/
    We annotate params/types separately in the docstring. This lets you do it in the arglist:

    f(a : "a thing",
    b : "another thing",
    c : "whoa",
    ):
    pass
    

    which is all accessible introspectively.

  • exception chaining: https://docs.python.org/3/whatsnew/3.0.html#changes-to-exceptions if handlers run into issues, you can throw new exceptions and have the old ones saved. could be nice for holding onto errors from C++ where we attempt handling/fixing in Python or try to reinvoke C++ or whatnot.

@printathing
Copy link

I would love to see this happen. I don't know enough about the code base to do it myself, but consider this a +1 for porting to python3. :)

@FlorianWilhelm
Copy link

+1
It would be really cool to have a Python 3 compatible interface

@redst4r
Copy link

redst4r commented Jun 24, 2016

+1

@gokceneraslan
Copy link

These are all addressed here: #466

@ptramsey
Copy link

It looks like the work was done, but it was never merged. Is this still a possibility?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants