In 2008 I started a Python 3-only project. Now, as the project is finally maturing, I feel the need for it to run also on Python 2, as I'd like to reach an audience that is as large as possible. Note that next to CPython 2, there's also Jython and IronPython that both seem to be stuck in Python 2.x land (but PyPy3 is in fairly good shape, it seems).
I did manage to backport the code to Python 2 some time ago, making sure the same codebase still runs on Python 3. Unfortunately, there are some things that make this unpleasant at the least. For example, metaclass definitions need to be specified in different ways in 2/3. It would be great if Python 2 would also support the Python 3 syntax. Similar to the re-addition of the unicode literal u"" to Python 3 and "from future import unicode_literals" in Python 2, this would be a minor change that could greatly simplify having a unified 2/3 codebase. Also, the Py2 str / Py3 unicode thing is very tricky to get right, but I'm not sure how this could be simplified.
There are also some Python 3 features that are not present in Python 2 which cannot be remedied by a third-party library. This stops me from adopting these Python 3 features. One example is Python 3's function annotation capability (which I'd like to use for type checking). Again, having support for these in Python 2 (even if they are simply parsed and ignored) would be great.
I think that the move to the (backward-incompatible) Python 3 was a good one, but in hindsight, perhaps more thought/effort should have been put into making the upgrade path as smooth as possible. Some tools have been given to the Python developer over the years (from future import <py3_thing>, u"") to help with this, but I think they should have been available from the start (yes, easy to say now). Something to remember for Python 4 or 5?
Some tools have been given to the Python developer over the years (from future import <py3_thing>, u"") to help with this, but I think they should have been available from the start (yes, easy to say now).
Just FYI: Almost all of them were. u'' were not, though.
6
u/brechtm May 28 '14 edited May 28 '14
In 2008 I started a Python 3-only project. Now, as the project is finally maturing, I feel the need for it to run also on Python 2, as I'd like to reach an audience that is as large as possible. Note that next to CPython 2, there's also Jython and IronPython that both seem to be stuck in Python 2.x land (but PyPy3 is in fairly good shape, it seems).
I did manage to backport the code to Python 2 some time ago, making sure the same codebase still runs on Python 3. Unfortunately, there are some things that make this unpleasant at the least. For example, metaclass definitions need to be specified in different ways in 2/3. It would be great if Python 2 would also support the Python 3 syntax. Similar to the re-addition of the unicode literal u"" to Python 3 and "from future import unicode_literals" in Python 2, this would be a minor change that could greatly simplify having a unified 2/3 codebase. Also, the Py2 str / Py3 unicode thing is very tricky to get right, but I'm not sure how this could be simplified.
There are also some Python 3 features that are not present in Python 2 which cannot be remedied by a third-party library. This stops me from adopting these Python 3 features. One example is Python 3's function annotation capability (which I'd like to use for type checking). Again, having support for these in Python 2 (even if they are simply parsed and ignored) would be great.
I think that the move to the (backward-incompatible) Python 3 was a good one, but in hindsight, perhaps more thought/effort should have been put into making the upgrade path as smooth as possible. Some tools have been given to the Python developer over the years (from future import <py3_thing>, u"") to help with this, but I think they should have been available from the start (yes, easy to say now). Something to remember for Python 4 or 5?