Table of Contents
回复内容:
Home Backend Development Python Tutorial Python 3 正在毁灭 Python 吗?

Python 3 正在毁灭 Python 吗?

Jun 06, 2016 pm 04:23 PM
bytes json python yaml

... Python 2最重要的一个优势在于拥有众多的第三方库,可以用来做任何事情,但是Python 3没有这个优势。诚然,有很多的库已经移植到Python 3了,但是有更多的库没有移植,也不容易移植。例如,你需要解析 X,但是X不像YAML和JSON那样容易解析。很可能有一个第三方的解析器可供选择,但是只可以用Python 2,而没有针对Python 3的移植版本。此外,加之Python 2中的字节字符串(str)和Python 3 中的字节字符串(bytes)之间有着功能上的差异,使得这更难移植。而事实上,移植它非常困难,并且需要很多的小技巧(trick)来兼容Python 2和Python 3。所以,你有两种选择,要么使用Python 2 (已经不建议使用的语言)快速的开发你的程序,但这会花费你十倍以上的时间去移植相关的库(以及所有的依赖)。要么,使用另一门同样拥有很多库的编程语言,但是不用再困扰于Python 2 / 3之间的问题。第二种选择显然不受欢迎,因为如果我们这样做了,在我们的生产环境中已经有很多Python 3的程序了并且大部分Python 2的库需要被移植。不管这些情况是否存在,人们要么继续使用Python 2开发程序,要么选择另一门不会打自己脸的语言...
文章链接:Python 3 正在毁灭 Python

回复内容:

谢邀。先总结一下该文观点
  1. Python 2.x的优势在于拥有众多的第三方库,虽然有很多库已经移植到Python 3.x,但也有很多没有移植,而且有很多库很难移植。
  2. 已有的Python 2.x项目可以无缝移植到Python 2.x的新版本上,而移植到Python 3.x上将更难,需要花费更多的人力物力。
  3. 大多数比较受欢迎并且支持兼容Python 2和Python3的库是通过运行在各自平台上的语言子集(subset)来写的。
  4. 最好的办法是Fork 2.7制作2.8,但官方却不支持这种做法。
该文作者说得很有道理,但我觉得Python 3.x并不会毁灭Python,会令Python社区变得更好。
  1. 第三方库现在越来越多库已经转向兼容Python 3.x,看PyPI上的列表pypi.python.org/pypi?。是有些库使用了所谓语言子集来实现兼容Python 2 & 3,或者是使用six这个module来帮助处理跨Py2和Py3的兼容问题,这些有可能会影响效率,但是,对于整个程序而言,相信核心模块的算法优化带来的性能提升会远大于这些损失。而且有2to3.py这个脚本可以帮助转换生成Py3 Only的脚本来发布,完全可以做到自动化。
  2. 如果是现有的项目,相信很多都还处理Py 2.4-2.6的阶段吧,相信连Py 2.7都不会到,何况更新的库。这些老旧代码,相信有一些库的升级版也不一定能支持到
  3. Python 3把bytes和str的行为分开,是一件好事,终于把一个历史遗留下来的错误fix了,居然有人说不好?
  4. Python 3每次升级都会带来新的stdlib,会fix掉一些错误,还可能会加入新的语法。比如Python 3.4.x里面新的asyncio库,最爱!
旧的项目,stays in Python 2。若你要开启一个新的项目,Why not choose Python 3? 新生代py程序员可能更愿意用py3,各种教辅资料也会慢慢转向py3。py2到3就是进步,C语言还几十年几乎不变呢。向下兼容可能成为发展的阻碍,看看Windows。Python依然是主流语言,随着py2停滞开发,py3必然会慢慢替代py2,不断加入新特性和修复以前的设计错误,使之成为更好用的工具。不能因为你习惯2,不想接受新东西就排斥3,没好处的,就像WinXP与win7,新软硬件很多已不再支持XP 如果python3改名叫python++可能就没争议了。。。 不会,python3只会毁灭python2,因为这本就是它出现的意义 Python3 开发了6年,毫无建树。Python3没有革命性的创新,又不向下兼容。
照这样折腾下去Python真的要灭亡了。

反观PHP这几年一直在蓬勃发展,命名空间,包管理,HHVM,PHPng,还有异步并行的Swoole。曾经Python说自己是下一个PHP。结果呢。。。

其他语言如Golang,Node.js也逐渐火起来了。Python还是那样不温不火。可以说Python3这6年真的是致命错误。 1 C++是一个和C完全不同的语言,但是它向下兼容C
2 看不出Python3有任何理由不兼容Python2的语法。因此,唯一可以解释的,就是Python官方希望像一个独裁者一样领导社区,“反对我的都去死”。 那么社区的回应就是“独裁者去死”。
3 Python3对于Python2的语言特性优势,根本不足以打动Python2社区。
4 既然Python开源,而且版权限制比GPL还弱, 那么一旦Python官方停止对2.x的支持,一定会有社区自发维护的版本,不会比官方做得差。
5 既然得罪了社区,那么得到的回应就会有很多开发者抵制Python3,坚决不会将他们开发的库升级到3 新手学,干下哪个版本啊? 因为我在c++界混了那么多年所以我很吊,所以你们该听我说说话:
python的优势就是库多,我能快速抄袭别人的库,从而瞬间开发。
然而python3不兼容我用的库。
什么,你说移植?那种脏活累活怎么能让我这么有经验,这么高贵优雅的人去干!!!
我建议你们赶紧fork出来一个我能继续用的版本,最好啥也不改,以便于我即能什么都不用改我的码,又能声称我用的是最新版本,以便装逼
其他人的建议都不值一提,你们要是不听我的,就会死的跟perl社区一样惨。
——作者精神概要 Python 3的原罪就在于break了back compatibility,并且没有成功的说服开发者为什么他们需要迁移到Python 3上来。

但要说Python 3会杀死Python我觉得实在是言过其实,Python的生态系统摆在那里,可能在一些方面被其他语言和技术超过,但是总体而言地位依然是稳固的,毕竟在大多数应用场景下,它的性能并不是一个大的问题。

不过负面影响总是存在的。Python 2.x于3.x这个胶着的状态,在社区造成了很大的分歧。而这个分歧拖下去的时间越长,对于Python未来的发展就越不利。为什么呢?因为其他竞争对手都在快速的演进。例如在最重要的web开发领域,node.js和Go正在吸引越来越多的注意力。特别是Go,syntax和Python差别不大,out-of-box的性能却高了不止一个数量级。这促使不少的开发者,尤其是那种愿意尝试新技术并且广为传播的(所谓的evangelist),在面对2to3这个选择的时候,索性直接将整个技术栈换成Go。

个人而言,为什么不愿意迁移到Python 3呢?一句话:Python 2 just works。Python 3缺乏让人眼前一亮,想要跃跃欲试的feature upgrade。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is there any mobile app that can convert XML into PDF? Is there any mobile app that can convert XML into PDF? Apr 02, 2025 pm 08:54 PM

An application that converts XML directly to PDF cannot be found because they are two fundamentally different formats. XML is used to store data, while PDF is used to display documents. To complete the transformation, you can use programming languages ​​and libraries such as Python and ReportLab to parse XML data and generate PDF documents.

Is the conversion speed fast when converting XML to PDF on mobile phone? Is the conversion speed fast when converting XML to PDF on mobile phone? Apr 02, 2025 pm 10:09 PM

The speed of mobile XML to PDF depends on the following factors: the complexity of XML structure. Mobile hardware configuration conversion method (library, algorithm) code quality optimization methods (select efficient libraries, optimize algorithms, cache data, and utilize multi-threading). Overall, there is no absolute answer and it needs to be optimized according to the specific situation.

How to convert XML files to PDF on your phone? How to convert XML files to PDF on your phone? Apr 02, 2025 pm 10:12 PM

It is impossible to complete XML to PDF conversion directly on your phone with a single application. It is necessary to use cloud services, which can be achieved through two steps: 1. Convert XML to PDF in the cloud, 2. Access or download the converted PDF file on the mobile phone.

How to control the size of XML converted to images? How to control the size of XML converted to images? Apr 02, 2025 pm 07:24 PM

To generate images through XML, you need to use graph libraries (such as Pillow and JFreeChart) as bridges to generate images based on metadata (size, color) in XML. The key to controlling the size of the image is to adjust the values ​​of the <width> and <height> tags in XML. However, in practical applications, the complexity of XML structure, the fineness of graph drawing, the speed of image generation and memory consumption, and the selection of image formats all have an impact on the generated image size. Therefore, it is necessary to have a deep understanding of XML structure, proficient in the graphics library, and consider factors such as optimization algorithms and image format selection.

How to open xml format How to open xml format Apr 02, 2025 pm 09:00 PM

Use most text editors to open XML files; if you need a more intuitive tree display, you can use an XML editor, such as Oxygen XML Editor or XMLSpy; if you process XML data in a program, you need to use a programming language (such as Python) and XML libraries (such as xml.etree.ElementTree) to parse.

Recommended XML formatting tool Recommended XML formatting tool Apr 02, 2025 pm 09:03 PM

XML formatting tools can type code according to rules to improve readability and understanding. When selecting a tool, pay attention to customization capabilities, handling of special circumstances, performance and ease of use. Commonly used tool types include online tools, IDE plug-ins, and command-line tools.

Is there a mobile app that can convert XML into PDF? Is there a mobile app that can convert XML into PDF? Apr 02, 2025 pm 09:45 PM

There is no APP that can convert all XML files into PDFs because the XML structure is flexible and diverse. The core of XML to PDF is to convert the data structure into a page layout, which requires parsing XML and generating PDF. Common methods include parsing XML using Python libraries such as ElementTree and generating PDFs using ReportLab library. For complex XML, it may be necessary to use XSLT transformation structures. When optimizing performance, consider using multithreaded or multiprocesses and select the appropriate library.

What is the function of C language sum? What is the function of C language sum? Apr 03, 2025 pm 02:21 PM

There is no built-in sum function in C language, so it needs to be written by yourself. Sum can be achieved by traversing the array and accumulating elements: Loop version: Sum is calculated using for loop and array length. Pointer version: Use pointers to point to array elements, and efficient summing is achieved through self-increment pointers. Dynamically allocate array version: Dynamically allocate arrays and manage memory yourself, ensuring that allocated memory is freed to prevent memory leaks.

See all articles