[openstack-dev] [nova] Port Nova to Python 3

Victor Stinner vstinner at redhat.com
Fri Apr 24 13:13:14 UTC 2015


Hi,

> If written to use python 3, I hope it will use all the new features of 
> python 3.4 moving forward.

The spec adds Python 3 support, but it keeps Python 2 support. It's too early to drop Python 2, Nova is deployed everywhere with Python 2.


> For example, argument annotations, coroutines, asyncio, etc.

Argument annotations are not used in practice :-( There is a PEP under review which targets the future Python 3.5 version:

   https://www.python.org/dev/peps/pep-0484/

I'm working actively on asyncio. I wrote a spec to replace eventlet with asyncio:

   https://review.openstack.org/#/c/153298/
   superseded by: https://review.openstack.org/#/c/164035/

For OpenStack, I ported asyncio to Python 2: it's the Trollius project:

   https://trollius.readthedocs.org/

I would also prefer to be able to use new shiny Python 3 features, but it's not possible yet. We have to move step by step. There is no choice like "Python 2 only" or "Python 3 only with new Python 3 features". Changes must be done incrementally in OpenStack. We all know that.


> At my last workplace, we tried to make our project python2 and 3
> compatible (ie, you could run it under 2.7 or 3.3+) but this was
> the worst of all worlds.

Does it mean that you are against the whole spec?

I don't know any Python project in the wild which was really ported to Python 3: drop Python 2 support at the same time. Supporting only Python 3 only slowly becomes a good choice for *new* projects.

All projects are ported by adding Python 3 support in addition to Python 2 support. The six module is a great module to limit changes on the source code.

See my early draft patch to port nova to Python 3:

   https://github.com/haypo/nova/commit/bad54bc2b278c7c7cb7fa6cc73d03c70138bd89d

Joe Goron wrote "I like how the sha1 starts with 'bad'. Overall that is a pretty small patch." ;-)

Victor



More information about the OpenStack-dev mailing list