程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python standard library is about to undergo slimming surgery

編輯:Python


Python A unique concept of community is “ Built in battery ”(Batteries Included), refer to Python With its own rich and diverse standard library , Open the box , Full of motivation . According to official documents ,Python Built in 200 Multiple standard libraries , They are for Python The popularity of .

however ,Python Has developed 30 year , Many standard libraries are out of date , Already in “ Electric leakage ” 了 , This is for the development of language , Not a good thing .

stay 2019 Official in PyCon After the meeting ,PEP-594 Was brought up , It aims to move the standard library once “ Operation ”, Eliminate poor quality 、 Backward function 、 Code obsolete standard library , Give Way Python Keep light and efficient , Continue to be full of vitality .

at that time , Brother cat learned the news , He wrote an article with great interest 《 Chat Python The built-in battery 》( Click here to read ), To the general public Python Developers convey this good news .

at that time ,PEP-594 In draft status , I didn't expect it to be three years in a flash , Now this PEP Finally accepted !

from 3.11 Version to 3.13 edition ,Python Built in battery “ Slimming surgery ” There will be .

Let's wish it better and better , More and more healthy !

from Python contributor Christian Heimes and Brett Cannon A proposed , from Python Remove obsolete and unmaintained modules from the standard library Python Enhancement Proposal (PEP) 594 Has been approved by . The proposal was originally made in 2019 Submitted in , But only recently (3 month 11 Japan ) Approved for Python 3.11.

With this PEP,Python 3.11 Some modules are marked as deprecated ,Python 3.12 Will be the last version to include these modules . stay Python 3.13 in , Modules that are not recommended will be completely removed .


this PEP A list of standard library modules to be deleted from the standard library is proposed . Most of these modules are in historical data format ( for example Commodore and SUN File format )、API And the operating system that has long been replaced ( for example Mac OS 9), Or there are security risks and better alternatives ( Such as password and login ) Module .

all the time ,Python All have “batteries included” Idea ; The goal is to provide a common standard library to handle many common development tasks , It doesn't have to be written for users Web Server or parse email to figure out how to download and install separate packages .

But as time goes by ,PyPI(née Cheeseshop)、setuptools and pip The introduction of , Downloading and installing packages becomes simple and straightforward .Python Now it also has a rich and dynamic third-party package ecosystem . On the other hand ,Python Our standard library is full of disorderly 、 Unnecessary functional duplication and dispensable features .

Based on this , Officials think :

  • Any additional module will add Python The maintenance cost of the core development team . Team resources are limited , Reduced maintenance costs can free up development time for other improvements .

  • Modules in the standard library are often favored , And regarded as a practical solution to the problem . Most users will only choose a third-party module to replace... If they have a compelling reason stdlib modular , for example , use lxml replace xml. Delete unmaintained stdlib Modules increase the opportunity for community contributed modules to be widely used .

  • A simplified standard library is beneficial to platforms with limited resources , For example, only a few hundred KB A device for storing space ( Such as BBC Micro:bit).BeeWare or WebAssembly( Such as pyodide) Wait for... On the mobile platform Python Also benefit from reduced downloads .

this PEP Abandoned modules in either because their removal is the least controversial , Or the most beneficial . for example , The least controversial is 30 Multimedia format years ago , Such as sunau Audio format , stay 80 Used in the late s SPARC and NeXT The workstation .crypt The module has fundamental flaws , It can be better solved outside the standard library .

Besides , The PEP Some modules are also specified as modules that are not planned to be deleted . Some modules have been abandoned in several versions , Or it doesn't seem necessary at first glance . However , It is beneficial to keep these modules in the standard library , This is mainly for those who can't learn from PyPI The environment in which the software package is installed ; Include ftplib、optparse、 getopt as well as wave modular .

CPython Core developers Gregory P. Smith On approval PEP In the discussion group of ,PEP-594 from Python A series of undisputed... Have been deleted from the standard library 、 Very old 、 No maintained or outdated Libraries .Python The steering committee wants this PEP It's a one-off event , Future waste will be disposed of in different ways .

“ The solution revolves around how we define stdlib The ongoing discussion does not hinder this PEP. For us , Every few versions stdlib It seems worthwhile to conduct a periodic review of the contents of , In this way, we can avoid accumulating so much dead batteries, But this goes beyond this particular PEP The scope of the .”


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved