我想升级到python 3.5,但我使用的是旧版python 2.7软件包。 在python 3.5中运行遗留包是否容易? 我一直认为这不容易,但我做了一些搜索,看看我是不是错了,并没有提出太多。
我希望有一个多处理软件包允许3.5代码和2.7软件包之间的标准化切换,允许它们在自己的环境下独立运行,但与开发人员有点无缝。
我不是在谈论将我自己的代码转换为3.5,我说的是我使用的库,不会更新或由我更新。
I'd like to upgrade to python 3.5, but I use legacy python 2.7 packages. Is it easy to run legacy packages in python 3.5? I have been under the impression that this isn't easy, but I did a few searches to see if I'm wrong and didn't come up with much.
I would expect there to be a multiprocessing package that allows standardized hand-offs between 3.5 code and 2.7 packages, allowing them to run independently under their own environments, but being somewhat seamless to the developer.
I'm not talking about converting my own code to 3.5, I'm talking about libraries that I use that won't be updated for or by me.
最满意答案
如果您使用2.7支持的较新语法,例如围绕异常,和/或更好地使用从__future__导入的新功能,您可以更轻松地将代码转换为Python 3(最多不做任何更改) 。 我建议首先遵循这条路径,因为它可以逐步进行,而不会突然跳转到Python 3。
我认为具有不同版本的Python进程可以互操作,因为对象酸洗格式是兼容的,并且您可以明确地使用双方的特定酸洗协议版本来确保这一点。 不过,我认为任何一方的multiprocessing软件包都不会太有用。 考虑使用例如ZeroMQ作为更通用的解决方案。
If you used the newer syntax supported by 2.7, e.g. around exceptions, and/or, better yet, worked with new features imported from __future__, you'll have much easier time converting your code to Python 3 (up to no changes at all). I'd suggest to follow this path first, for it can be trod gradually, without an abrupt jump to Python 3.
I suppose Python processes with different versions can interoperate, because object pickling format is compatible, and you can explicitly use a specific pickling protocol version on both sides to ensure that. I don't think multiprocessing packages on either side would be too useful, though. Consider using e.g. ZeroMQ as a more general solution.
更多推荐
发布评论