码迷,mamicode.com
首页 > 编程语言 > 详细

Supporting Python 3(支持python3)——前言

时间:2015-09-01 18:36:31      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

前言

当我在2002年6月加入python-dev邮件列表时,“Python 3000"(在湖闻樟译注:即Python 3)的团队每隔几个月都会描述一个Python 开发团队希望他们实现的建议,但是因为兼容性的原因都没有办法做到。对我们来说为“Python 3000  可能是“做一些事意味着没有发生任何变化。

但是后来我们开始越来越经常地说在Python 3000可能发生的事。最终到了“Python 3000”因为内部程序员的惰性被经常引用成缩写“py3k”的时候。 然后我们开始相信像我们大肆宣传的那样py3k将会更加好。 It got to the point where Andrew Kuchling created PEP 3100 (which was the original PEP 3000, which I eventually took responsibility for) to keep track of the various ideas we had for py3k in late 2004 as it was obvious around that time that we were actually going to go through with the “crazy” idea of making Python 3000 happen. This all led to serious development starting in March 2006 and culminating in the release of Python 3.0 on December 3, 2008.

While all of this was happening, there were mixed feelings from the community about the feasibility/sanity of creating Python 3. When PEP 3100 was created in 2004, Python’s popularity took a very noticeable uptick. This trend continued and around 2006, when py3k development started in earnest, Python’s popularity exceeded that of Perl. So while Python was becoming one of the most popular dynamic programming languages in the world, the development team was beginning to create the next major version which would break compatibility with the version of the language that all of these people were now learning. Some people called us a little nuts for obvious reasons.

But we would like to think we knew what we were doing. While Python 2 is a great language, Guido and everyone on the development team knew it had its flaws (if it didn’t then we would not have been able to create a PEP with nearly 100 things we wanted to change). Guido also realized that more Python code would be written in the future then had been written to that point and into the future that would continue to be true. As a service to our community (and partly because it was fun) we decided we should try to fix some of our previous mistakes so that future Python code could be written better and faster than was possible with Python 2, hence why we created Python 3.

But while some considered us a little nuts to break compatibility with Python 2, We also realized that we didn’t want to leave our existing community behind and develop Python 3 only for new code. The development team knew as we created Python 3 that it was a superior language and so we wanted to share it with everyone by making sure they could bring their Python 2 code with them into their Python 3 work. From the beginning we made sure that the changes we made could either be warned against in the worst case, and automated in the best. Techniques we learned and tools we developed were used to port Python’s extensive standard library so as to learn from our own mistakes and make sure that other people could port their own code. We always kept in the back of our heads the goal of making porting Python 2 code as easy as possible.

The continual increase in the number of Python 3 projects available and the fact that all of the major Linux distributions ship with Python 3, or will do so in their next major release, is a testament that we didn’t screw up. Guido always said it would take 3 to 5 years for Python 3 to gain traction within the community. The constant trend of Python 3 projects being released is a testament that the timeline Guido set out is turning out to be true as major libraries have already been ported, allowing their dependents to make the switch themselves.

While some might question the utility in moving Python 2 code to Python 3, there are two things to keep in mind. One is that Python 3 is simply a nicer language than Python 2. While there are only a handful of major changes, it’s all of the little changes that add up to make the experience of programming Python 3 that much more pleasant than Python 2. It’s rather common to hear core developers say how they prefer coding in Python 3 over Python 2. I for one have simply stopped coding in Python 2 as it just feels slightly off compared to the more uniform feel of Python 3. And secondly, more code will be written in Python 3 than in Python 2 over the history of the Python language, so not porting means your project will eventually be left behind (this is already starting to happen for projects which have publicly said they will not switch, leading people to find alternatives for both their Python 2 and Python 3 code, to make sure they can switch to Python 3 when ready). Sitting idly by as the world changes around you is not a good thing to do if you want to stay relevant.

I still remember the day that Python 3 was released. It was the end of the workday and I was on IRC in #python-dev waiting for Barry Warsaw, the Python 3.0 release manager, to flip the switch on the release. When it was hit, I just swivelled around in my chair and told Guido that it was done; Python 3 was no longer a dream but an actual thing. I stood up, we gave each other an ecstatic high-five, and just smiled (the next day people asked us at work what we were so giddy about that night).

At that moment, and to this day, the thought that Python 3 would flop or not be worth the amount of time and effort my fellow core developers and I put into it never crossed my mind. And the fact that people care enough about seeing Python 3 work that there is now a book dedicated to helping people get from Python 2 to Python 3 is a testament that Python 3 has not, and will not, flop.


Supporting Python 3(支持python3)——前言

标签:

原文地址:http://my.oschina.net/soarwilldo/blog/500267

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!