您打算如何处理向 Python 3 的迁移? [英] How are you planning on handling the migration to Python 3?

查看:23
本文介绍了您打算如何处理向 Python 3 的迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到 Python 3 即将问世,我确信这是大多数 Python 开发人员心中的一个主题.一些让我们朝着正确方向前进的问题:

I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction:

  1. 您是要同时维护一个 python 2 和 python 3 版本,还是在完成后只拥有一个 python 3 版本?

  1. Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's finished?

  • 您是否已经开始或计划很快开始?还是打算等到最终版本出来再全面展开?

推荐答案

这是 Twisted 的总体规划.我本来打算写博客的,但后来我想:既然我能得到积分,为什么还要写博客呢?

Here's the general plan for Twisted. I was originally going to blog this, but then I thought: why blog about it when I could get points for it?

  1. 等到有人关心.

目前,没有人拥有 Python 3.在至少有一个实际用户站出来说我需要 Python 3.0 支持"之前,我们不会花费大量精力,并且除了有充分的理由之外3.0 看起来很闪亮.

Right now, nobody has Python 3. We're not going to spend a bunch of effort until at least one actual user has come forth and said "I need Python 3.0 support", and has a good reason for it aside from the fact that 3.0 looks shiny.

等到我们的依赖项迁移完毕.

像 Twisted 这样的大型系统有许多依赖项.首先,我们的包括:

A large system like Twisted has a number of dependencies. For starters, ours include:

  • Zope Interface
  • PyCrypto
  • PyOpenSSL
  • pywin32
  • PyGTK (though this dependency is sadly very light right now, by the time migration rolls around, I hope Twisted will have more GUI tools)
  • pyasn1
  • PyPAM
  • gmpy

其中一些项目有自己的依赖关系数组,所以我们也必须等待这些.

Some of these projects have their own array of dependencies so we'll have to wait for those as well.

等到有人关心帮助.

慈善地,有 5 个人在 Twisted 上工作 - 我说慈善地"是因为我也算在内,而且我已经好几个月没有承诺了.我们现在有 超过 1000 张开放票,如果能真正修复其中的一些,那就太好了——在花时间将其移植到该语言的全新版本之前,修复错误、添加功能并总体上使 Twisted 成为更好的产品.

There are, charitably, 5 people who work on Twisted - and I say "charitably" because that's counting me, and I haven't committed in months. We have over 1000 open tickets right now, and it would be nice to actually fix some of those — fix bugs, add features, and generally make Twisted a better product in its own right — before spending time on getting it ported over to a substantially new version of the language.

这可能包括 赞助商 足够关心我们支付费用,但我希望将会有大量关心 3.0 支持并希望帮助推动社区向前发展的志愿者涌入.

This potentially includes sponsors caring enough to pay for us to do it, but I hope that there will be an influx of volunteers who care about 3.0 support and want to help move the community forward.

听从 Guido 的建议.

这意味着我们不会不兼容地更改我们的 API,我们将遵循过渡发展Guido 去年发布的指南.首先是进行单元测试,然后在 Twisted 代码库上运行 2to3 转换工具.

This means we will not change our API incompatibly, and we will follow the transitional development guidelines that Guido posted last year. That starts with having unit tests, and running the 2to3 conversion tool over the Twisted codebase.

报告 2to3 工具的错误并提交补丁.

当我们真正使用它时,我预计将来运行 2to3 会出现很多问题.现在在 Twisted 上运行它需要很长时间,而且(上次我检查过,那是很久以前的事了)无法解析 Twisted 存储库中的一些文件,因此结果输出不会导入.我认为必须有大量来自小型项目的成功案例,并在该工具真正为我们工作之前进行大量的锤炼.

When we get to the point where we're actually using it, I anticipate that there will be a lot of problems with running 2to3 in the future. Running it over Twisted right now takes an extremely long time and (last I checked, which was quite a while ago) can't parse a few of the files in the Twisted repository, so the resulting output won't import. I think there will have to be a fair amount of success stories from small projects and a lot of hammering on the tool before it will actually work for us.

然而,Python 开发团队在响应我们的错误报告方面非常有帮助,对这些问题的早期响应令人鼓舞,所以我希望所有这些问题都能及时得到解决.

However, the Python development team has been very helpful in responding to our bug reports, and early responses to these problems have been encouraging, so I expect that all of these issues will be fixed in time.

保持 2.x 兼容性数年.

目前,Twisted 支持 python 2.3 到 2.5.目前,我们正在努力支持 2.6(我们显然必须在 3.0 之前完成!).我们的计划是根据长期支持的 Ubuntu 版本修改我们支持的 Python 版本- 包含 Python 2.5 的 8.04 版将支持到 2013 年.根据 Guido 的建议,我们需要放弃对 2.5 的支持才能支持 3.0,但我希望我们能找到解决方法(我们非常有创意版本兼容性黑客).

Right now, Twisted supports python 2.3 to 2.5. Currently, we're working on 2.6 support (which we'll obviously have to finish before 3.0!). Our plan is to we revise our supported versions of Python based on the long-term supported versions of Ubuntu - release 8.04, which includes Python 2.5, will be supported until 2013. According to Guido's advice we will need to drop support for 2.5 in order to support 3.0, but I am hoping we can find a way around that (we are pretty creative with version-compatibility hacks).

因此,我们计划至少在 2013 年之前支持 Python 2.5.两年后,Ubuntu 将发布另一个长期支持的 Ubuntu 版本:如果它们仍然存在,并且按计划进行,那就是 10.04.我个人猜测这将与 Python 2.x,也许是 python 2.8 一起提供,作为 /usr/bin/python,因为有大量的 Python 软件打包在发行版中,它需要很长一段时间来更新它.所以,从五年后的 2015 年,我们可以开始考虑放弃对 2.x 的支持.

So, we are planning to support Python 2.5 until at least 2013. In two years, Ubuntu will release another long-term supported version of Ubuntu: if they still exist, and stay on schedule, that will be 10.04. Personally I am guessing that this will ship with Python 2.x, perhaps python 2.8, as /usr/bin/python, because there is a huge amount of Python software packaged with the distribution and it will take a long time to update it all. So, five years from then, in 2015, we can start looking at dropping 2.x support.

在此期间,我们将继续遵循 Guido 关于迁移的建议:在我们的 2.x 代码库上运行 2to3,并修改 2.x 代码库以使其测试在两个版本中都能通过.

During this period, we will continue to follow Guido's advice about migration: running 2to3 over our 2.x codebase, and modifying the 2.x codebase to keep its tests passing in both versions.

这样做的结果是,直到我 35 岁生日之后,Python 3.x 才会成为 Twisted 的源代码语言——它将成为目标运行时(以及一组准则和限制)对于我的 python 2.x 代码.我希望在未来十年左右使用 Python 2.x 编写程序.

The upshot of this is that Python 3.x will not be a source language for Twisted until well after my 35th birthday — it will be a target runtime (and a set of guidelines and restrictions) for my python 2.x code. I expect to be writing programs in Python 2.x for the next ten years or so.

所以,这就是计划.我希望它在一年左右的时间里看起来保守得可笑.3.x 过渡很容易,每个人都快速升级.其他事情也可能发生:2.x 和 3.x 分支可能会聚,有人可能最终编写 3to2,或者另一个运行时(想到 PyPy)可能允许运行 2.x和 3.x 代码直接在同一个过程中,使我们的转换过程更容易.

So, that's the plan. I'm hoping that it ends up looking laughably conservative in a year or so; that the 3.x transition is easy as pie, and everyone rapidly upgrades. Other things could happen, too: the 2.x and 3.x branches could converge, someone might end up writing a 3to2, or another runtime (PyPy comes to mind) might allow for running 2.x and 3.x code in the same process directly, making our conversion process easier.

然而,就目前而言,我们假设,多年来,我们将拥有维护大型代码库的人员(或编写新代码并希望使用其他库的人员尚未迁移)仍然希望在 Twisted 中获得新功能和错误修复的人.我希望很快我们也会有希望在 python 3 上使用 Twisted 的前沿用户.我想尽可能长时间地为所有这些人提供积极的体验.

For the time being, however, we're assuming that, for many years, we will have people with large codebases they're maintaining (or people writing new code who want to use other libraries which have not yet been migrated) who still want new features and bug fixes in Twisted. Pretty soon I expect we will also have bleeding-edge users that want to use Twisted on python 3. I'd like to provide all of those people with a positive experience for as long as possible.

这篇关于您打算如何处理向 Python 3 的迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆