Movatterモバイル変換


[0]ホーム

URL:


Following system colour schemeSelected dark colour schemeSelected light colour scheme

Python Enhancement Proposals

PEP 3108 – Standard Library Reorganization

PEP 3108 – Standard Library Reorganization

Author:
Brett Cannon <brett at python.org>
Status:
Final
Type:
Standards Track
Created:
01-Jan-2007
Python-Version:
3.0
Post-History:
28-Apr-2008

Table of Contents

Note

The merging of profile/cProfile as of Python 3.3 did notoccur, and thus is considered abandoned (although it would beacceptable to do in the future).

Abstract

Just like the language itself, Python’s standard library (stdlib) hasgrown over the years to be very rich. But over time some moduleshave lost their need to be included with Python. There has also beenan introduction of a naming convention for modules since Python’sinception that not all modules follow.

Python 3.0 presents a chance to remove modules that do not havelong term usefulness. This chance also allows for the renaming ofmodules so that they follow thePython style guide. ThisPEP lists modules that should not be included in Python 3.0 or whichneed to be renamed.

Modules to Remove

Guido pronounced that “silly old stuff” is to be deleted from thestdlib for Py3K[7]. This is open-ended on purpose.Each module to be removed needs to have a justification as to why itshould no longer be distributed with Python. This can range from themodule being deprecated in Python 2.x to being for a platform that isno longer widely used.

This section of the PEP lists the various modules to be removed. Eachsubsection represents a different reason for modules to beremoved. Each module must have a specific justification on top ofbeing listed in a specific subsection so as to make sure only modulesthat truly deserve to be removed are in fact removed.

When a reason mentions how long it has been since a module has been“uniquely edited”, it is in reference to how long it has been since acheckin was done specifically for the module and not for a change thatapplied universally across the entire stdlib. If an edit time is notdenoted as “unique” then it is the last time the file was edited,period.

Previously deprecated [done]

PEP 4 lists all modules that have been deprecated in the stdlib.The specified motivations mirror those listed inPEP 4. All modules listedin the PEP at the time of the first alpha release of Python 3.0 willbe removed.

The entire contents of lib-old will also be removed. These moduleshave already been removed from being imported but are kept in thedistribution for Python for users that rely upon the code.

  • cfmfile
    • Documented as deprecated since Python 2.4 without an explicitreason.
  • cl
    • Documented as obsolete since Python 2.0 or earlier.
    • Interface to SGI hardware.
  • md5
    • Supplanted by thehashlib module.
  • mimetools
    • Documented as obsolete in a previous version.
    • Supplanted by theemail package.
  • MimeWriter
    • Supplanted by theemail package.
  • mimify
    • Supplanted by theemail package.
  • multifile
    • Supplanted by theemail package.
  • posixfile
    • Locking is better done byfcntl.lockf().
  • rfc822
    • Supplanted by theemail package.
  • sha
    • Supplanted by thehashlib package.
  • sv
    • Documented as obsolete since Python 2.0 or earlier.
    • Interface to obsolete SGI Indigo hardware.
  • timing
    • Documented as obsolete since Python 2.0 or earlier.
    • time.clock() gives better time resolution.

Platform-specific with minimal use [done]

Python supports many platforms, some of which are not widely used ormaintained.And on some of these platforms there are modules that have limited useto people on those platforms. Because of their limited usefulness itwould be better to no longer burden the Python development team withtheir maintenance.

The modules mentioned below are documented. All undocumented modulesfor the specified platforms will also be removed.

IRIX

The IRIX operating system is no longer produced[13].Removing all modules from the plat-irix[56] directory has been deemedreasonable because of this fact.

  • AL/al
    • Provides sound support on Indy and Indigo workstations.
    • Both workstations are no longer available.
    • Code has not been uniquely edited in three years.
  • cd/CD
    • CD drive control for SGI systems.
    • SGI no longer sells machines with IRIX on them.
    • Code has not been uniquely edited in 14 years.
  • cddb
    • Undocumented.
  • cdplayer
    • Undocumented.
  • cl/CL/CL_old
    • Compression library for SGI systems.
    • SGI no longer sells machines with IRIX on them.
    • Code has not been uniquely edited in 14 years.
  • DEVICE/GL/gl/cgen/cgensuport
    • GL access, which is the predecessor to OpenGL.
    • Has not been edited in at least eight years.
    • Third-party libraries provide better support (PyOpenGL[10]).
  • ERRNO
    • Undocumented.
  • FILE
    • Undocumented.
  • FL/fl/flp
    • Wrapper for the FORMS library[14]
    • FORMS has not been edited in 12 years.
    • Library is not widely used.
    • First eight hits on Google are for Python docs for fl.
  • fm
    • Wrapper to the IRIS Font Manager library.
    • Only available on SGI machines which no longer come with IRIX.
  • GET
    • Undocumented.
  • GLWS
    • Undocumented.
  • imgfile
    • Wrapper for SGI libimage library for imglib image files(.rgb files).
    • Python Imaging Library provides read-only support[11].
    • Not uniquely edited in 13 years.
  • IN
    • Undocumented.
  • IOCTL
    • Undocumented.
  • jpeg
    • Wrapper for JPEG (de)compressor.
    • Code not uniquely edited in nine years.
    • Third-party libraries provide better support(Python Imaging Library[11]).
  • panel
    • Undocumented.
  • panelparser
    • Undocumented.
  • readcd
    • Undocumented.
  • SV
    • Undocumented.
  • torgb
    • Undocumented.
  • WAIT
    • Undocumented.

Mac-specific modules

The Mac-specific modules are not well-maintained (e.g., the bgentool used to auto-generate many of the modules has never beenupdated to support UCS-4). It is also not Python’s place to maintainsuch a large amount of OS-specific modules. Thus all modules underLib/plat-mac andMac are to be removed.

A stub module for proxy access will be provided for use by urllib.

  • _builtinSuites
    • Undocumented.
    • Package under lib-scriptpackages.
  • Audio_mac
    • Undocumented.
  • aepack
    • OSA support is better through third-party modules.
    • Hard-coded endianness which breaks on Intel Macs.
    • Might need to rename if Carbon package dependent.
  • aetools
    • See aepack.
  • aetypes
    • See aepack.
  • applesingle
    • Undocumented.
    • AppleSingle is a binary file format for A/UX.
    • A/UX no longer distributed.
  • appletrawmain
    • Undocumented.
  • appletrunner
    • Undocumented.
  • argvemulator
    • Undocumented.
  • autoGIL
    • Very bad model for using Python with the CFRunLoop.
  • bgenlocations
    • Undocumented.
  • buildtools
    • Documented as deprecated since Python 2.3 without an explicitreason.
  • bundlebuilder
    • Undocumented.
  • Carbon
    • Carbon development has stopped.
    • Does not support 64-bit systems completely.
    • Dependent on bgen which has never been updated to support UCS-4Unicode builds of Python.
  • CodeWarrior
    • Undocumented.
    • Package under lib-scriptpackages.
  • ColorPicker
    • Better to use Cocoa for GUIs.
  • EasyDialogs
    • Better to use Cocoa for GUIs.
  • Explorer
    • Undocumented.
    • Package under lib-scriptpackages.
  • Finder
    • Undocumented.
    • Package under lib-scriptpackages.
  • findertools
    • No longer useful.
  • FrameWork
    • Poorly documented.
    • Not updated to support Carbon Events.
  • gensuitemodule
    • See aepack.
  • ic
  • icglue
  • icopen
    • Not needed on OS X.
    • Meant to replace ‘open’ which is usually a bad thing to do.
  • macerrors
    • Undocumented.
  • MacOS
    • Would also mean the removal of binhex.
  • macostools
  • macresource
    • Undocumented.
  • MiniAEFrame
    • See aepack.
  • Nav
    • Undocumented.
  • Netscape
    • Undocumented.
    • Package under lib-scriptpackages.
  • OSATerminology
  • pimp
    • Undocumented.
  • PixMapWrapper
    • Undocumented.
  • StdSuites
    • Undocumented.
    • Package under lib-scriptpackages.
  • SystemEvents
    • Undocumented.
    • Package under lib-scriptpackages.
  • Terminal
    • Undocumented.
    • Package under lib-scriptpackages.
  • terminalcommand
    • Undocumented.
  • videoreader
    • No longer used.
  • W
    • No longer distributed with Python.

Solaris

  • SUNAUDIODEV/sunaudiodev
    • Access to the sound card on Sun machines.
    • Code not uniquely edited in over eight years.

Hardly used [done]

Some platform-independent modules are rarely used. There are a number ofpossible explanations for this, including, ease of reimplementation, verysmall audience or lack of adherence to more modern standards.

  • audiodev
    • Undocumented.
    • Not edited in five years.
  • imputil
    • Undocumented.
    • Never updated to support absolute imports.
  • mutex
    • Easy to implement using a semaphore and a queue.
    • Cannot block on a lock attempt.
    • Not uniquely edited since its addition 15 years ago.
    • Only useful with the ‘sched’ module.
    • Not thread-safe.
  • stringold
    • Function versions of the methods on string objects.
    • Obsolete since Python 1.6.
    • Any functionality not in the string object or module will be movedto the string module (mostly constants).
  • sunaudio
    • Undocumented.
    • Not edited in over seven years.
    • Thesunau module provides similar abilities.
  • toaiff
    • Undocumented.
    • Requiressox library to be installed on the system.
  • user
    • Easily handled by allowing the application specify its ownmodule name, check for existence, and import if found.
  • new
    • Just a rebinding of names from the ‘types’ module.
    • Can also calltype built-in to get most types easily.
    • Docstring states the module is no longer useful as of revision27241 (2002-06-15).
  • pure
    • Written before Pure Atria was bought by Rational which was thenbought by IBM (in other words, very old).
  • test.testall
    • From the days before regrtest.

Obsolete

Becoming obsolete signifies that either another module in the stdlibor a widely distributed third-party library provides a better solutionfor what the module is meant for.

  • Bastion/rexec [done]
    • Restricted execution / security.
    • Turned off in Python 2.3.
    • Modules deemed unsafe.
  • bsddb185 [done]
    • Superseded by bsddb3
    • Not built by default.
    • Documentation specifies that the “module should never be useddirectly in new code”.
    • Available externally fromPyPI.
  • Canvas [done]
  • commands [done]
    • subprocess module replaces it (PEP 324).
    • Remove getstatus(), move rest to subprocess.
  • compiler [done]
    • Having to maintain both the built-in compiler and the stdlibpackage is redundant[17].
    • The AST created by the compiler is available[16].
    • Mechanism to compile from an AST needs to be added.
  • dircache [done]
    • Negligible use.
    • Easily replicated.
  • dl [done]
    • ctypes provides better support for same functionality.
  • fpformat [done]
    • All functionality is supported by string interpolation.
  • htmllib [done]
    • Superseded by HTMLParser.
  • ihooks [done]
    • Undocumented.
    • For use with rexec which has been turned off since Python 2.3.
  • imageop [done]
    • Better support by third-party libraries(Python Imaging Library[11]).
    • Unit tests relied on rgbimg and imgfile.
      • rgbimg was removed in Python 2.6.
      • imgfile slated for removal in this PEP.
  • linuxaudiodev [done]
    • Replaced by ossaudiodev.
  • mhlib [done]
    • Should be removed as an individual module; usemailboxinstead.
  • popen2 [done]
    • subprocess module replaces it (PEP 324).
  • sgmllib [done]
    • Does not fully parse SGML.
    • In the stdlib for support to htmllib which is slated for removal.
  • sre [done]
    • Previously deprecated; importre instead.
  • stat [TODO need to move all uses over toos.stat()]
    • os.stat() now returns a tuple with attributes.
    • Functions in the module should be made into methods for the objectreturned by os.stat.
  • statvfs [done]
    • os.statvfs now returns a tuple with attributes.
  • thread [done]
    • People should use ‘threading’ instead.
      • Rename ‘thread’ to _thread.
      • Deprecate dummy_thread and rename _dummy_thread.
      • Move thread.get_ident over to threading.
    • Guido has previously supported the deprecation[8].
  • urllib [done]
    • Superseded by urllib2.
    • Functionality unique to urllib will be kept in theurllib package.
  • UserDict [done: 3.0] [TODO handle 2.6]
    • Not as useful since types can be a superclass.
    • Useful bits moved to the ‘collections’ module.
  • UserList/UserString [done]
    • Not useful since types can be a superclass.
    • Moved to the ‘collections’ module.

Maintenance Burden

Over the years, certain modules have become a heavy burden uponpython-dev to maintain. In situations like this, it is better for themodule to be given to the community to maintain to free python-dev tofocus more on language support and other modules in the standardlibrary that do not take up an undue amount of time and effort.

  • bsddb3
    • Externally maintained athttp://www.jcea.es/programacion/pybsddb.htm .
    • Consistent testing instability.
    • Berkeley DB follows a different release schedule than Python,leading to the bindings not necessarily being in sync with what isavailable.

Modules to Rename

Many modules existed inthe stdlib beforePEP 8 came into existence. This hasled to some naming inconsistencies and namespace bloat that should beaddressed.

PEP 8 violations [done]

PEP 8 specifies that modules “should have short, all-lowercase names”where “underscores can be used … if it improves readability”.The use of underscores is discouraged in package names.The following modules violatePEP 8 and are not somehow being renamedby being moved to a package.

Current NameReplacement Name
_winregwinreg
ConfigParserconfigparser
copy_regcopyreg
Queuequeue
SocketServersocketserver

Merging C and Python implementations of the same interface

Several interfaces have both a Python and C implementation. While itis great to have a C implementation for speed with a Pythonimplementation as fallback, there is no need to expose the twoimplementations independently in the stdlib. For Python 3.0 allinterfaces with two implementations will be merged into a singlepublic interface.

The C module is to be given a leading underscore to delineate the factthat it is not the reference implementation (the Python implementationis). This means that any semantic difference between the C and Pythonversions must be dealt with before Python 3.0 or else the Cimplementation will be removed until it can be fixed.

One interface that is not listed below is xml.etree.ElementTree. Thisis an externally maintained module and thus is not under the directcontrol of the Python development team for renaming. SeeOpenIssues for a discussion on this.

  • pickle/cPickle [done]
    • Rename cPickle to _pickle.
    • Semantic completeness of C implementationnot verified.
  • profile/cProfile [TODO]
    • Rename cProfile to _profile.
    • Semantic completeness of C implementationnot verified.
  • StringIO/cStringIO [done]
    • Add the class to the ‘io’ module.

No public, documented interface [done]

There are several modules in the stdlib that have no defined publicinterface. These modules exist as support code for other modules thatare exposed. Because they are not meant to be used directly theyshould be renamed to reflect this fact.

Current NameReplacement Name
markupbase_markupbase

Poorly chosen names [done]

A few modules have names that were poorly chosen in hindsight. Theyshould be renamed so as to prevent their bad name from perpetuatingbeyond the 2.x series.

Current NameReplacement Name
reprreprlib
test.test_supporttest.support

Grouping of modules [done]

As the stdlib has grown, several areas within it have expanded toinclude multiple modules (e.g., support for database files). Itthus makes sense to group related modules into packages.

dbm package

Current NameReplacement Name
anydbmdbm.__init__[1]
dbhashdbm.bsd
dbmdbm.ndbm
dumbdmdbm.dumb
gdbmdbm.gnu
whichdbdbm.__init__[1]
[1] (1,2)
dbm.__init__ can combineanybdbm andwhichdb sincethe public API for both modules has no name conflict and thetwo modules have closely related usage.

html package

Current NameReplacement Name
HTMLParserhtml.parser
htmlentitydefshtml.entities

http package

Current NameReplacement Name
httplibhttp.client
BaseHTTPServerhttp.server[2]
CGIHTTPServerhttp.server[2]
SimpleHTTPServerhttp.server[2]
Cookiehttp.cookies
cookielibhttp.cookiejar
[2] (1,2,3)
Thehttp.server module can combine the specified modulessafely as they have no naming conflicts.

tkinter package

Current NameReplacement Name
Dialogtkinter.dialog
FileDialogtkinter.filedialog[4]
FixTktkinter._fix
ScrolledTexttkinter.scrolledtext
SimpleDialogtkinter.simpledialog[5]
Tixtkinter.tix
Tkconstantstkinter.constants
Tkdndtkinter.dnd
Tkintertkinter.__init__
tkColorChoosertkinter.colorchooser
tkCommonDialogtkinter.commondialog
tkFileDialogtkinter.filedialog[4]
tkFonttkinter.font
tkMessageBoxtkinter.messagebox
tkSimpleDialogtkinter.simpledialog[5]
turtletkinter.turtle
[4] (1,2)
tkinter.filedialog can safely combineFileDialog andtkFileDialog as there are no naming conflicts.
[5] (1,2)
tkinter.simpledialog can safely combineSimpleDialogandtkSimpleDialog have no naming conflicts.

urllib package

Originally this new package was to be namedurl, but because ofthe common use of the name as a variable, it has been deemed betterto keep the nameurllib and instead shift existing modules aroundinto a new package.

Current NameReplacement Name
urllib2urllib.request, urllib.error
urlparseurllib.parse
urlliburllib.parse, urllib.request, urllib.error[6]
robotparserurllib.robotparser
[6]
The quoting-related functions fromurllib will be addedtourllib.parse.urllib.URLOpener andurllib.FancyUrlOpener will be added tourllib.requestas long as the documentation for both modules is updated.

xmlrpc package

Current NameReplacement Name
xmlrpclibxmlrpc.client
DocXMLRPCServerxmlrpc.server[3]
SimpleXMLRPCServerxmlrpc.server[3]
[3] (1,2)
The modules being combined intoxmlrpc.server have nonaming conflicts and thus can safely be merged.

Transition Plan

Issues

Issues related to this PEP:

For modules to be removed

For module removals, it is easiest to remove the module first inPython 3.0 to see where dependencies exist. This makes findingcode that (possibly) requires the suppression of theDeprecationWarning easier.

In Python 3.0

  1. Remove the module.
  2. Remove related tests.
  3. Remove all documentation (typically the module’s documentationfile and its entry in a file for the Library Reference).
  4. EditModules/Setup.dist andsetup.py if needed.
  5. Run the regression test suite (using-uall); watch out fortests that are skipped because an import failed for the removedmodule.
  6. Check in the change (with an appropriateMisc/NEWS entry).
  7. Update this PEP noting that the 3.0 step is done.

In Python 2.6

  1. Add the following code to the deprecated module if it isimplemented in Python as the first piece of executed code(adjusting the module name and thewarnings import andneeded):
    fromwarningsimportwarnpy3kwarnpy3k("the XXX module has been removed in Python 3.0",stacklevel=2)delwarnpy3k

    or the following if it is an extension module:

    if(PyErr_WarnPy3k("the XXX module has been removed in ""Python 3.0",2)<0)return;

    (the Python-Dev TextMate bundle, available fromMisc/TextMate,contains a command that will generate all of this for you).

  2. Update the documentation. For modules with their own documentationfile, use the:deprecated: option with themodule directivealong with thedeprecated directive, stating the deprecationis occurring in 2.6, but is for the module’s removal in 3.0.:
    .. deprecated:: 2.6   The :mod:`XXX` module has been removed in Python 3.0.

    For modules simply listed in a file (e.g.,undoc.rst), use thewarning directive.

  3. Add the module to the module deletion test intest_py3kwarn.
  4. Suppress the warning in the module’s test code using
    test.test_support.import_module(name,deprecated=True).
  5. Check in the change w/ appropriateMisc/NEWS entry (blockthis checkin inpy3k!).
  6. Update this PEP noting that the 2.6 step is done.

Renaming of modules

Support in the 2to3 refactoring tool for renames will be used to helppeople transition to new module names[9]. Import statements will be rewritten so that only the importstatement and none of the rest of the code needs to be touched. Thiswill be accomplished by using theas keyword in import statementsto bind in the module namespace to the old name while importing basedon the new name (when the keyword is not already used, otherwise thereassigned name should be left alone and only the module that isimported needs to be changed). Thefix_imports fixer is anexample of how to approach this.

Python 3.0

  1. Update 2to3 in the sandbox to support the rename.
  2. Usesvnmove to rename the module.
  3. Update all import statements in the stdlib to use the new name(use 2to3’sfix_imports fixer for the easiest solution).
  4. Rename the module in its own documentation.
  5. Update all references in the documentation from the old name tothe new name.
  6. Runregrtest.py-uall to verify the rename worked.
  7. Add an entry inMisc/NEWS.
  8. Commit the changes.

Python 2.6

  1. In the module’s documentation, add a note mentioning that the module isrenamed in Python 3.0:
    .. note::   The :mod:`OLDNAME` module has been renamed to :mod:`NEWNAME` in   Python 3.0.
  2. Commit the documentation change.
  3. Block the revision in py3k.

Open Issues

Renaming of modules maintained outside of the stdlib

xml.etree.ElementTree not only does not meetPEP 8 naming standardsbut it also has an exposed C implementation. It is anexternally maintained package, thoughPEP 360. A request will bemade for the maintainer to change the name so that it matchesPEP 8and hides the C implementation.

Rejected Ideas

Modules that were originally suggested for removal

  • asynchat/asyncore
    • Josiah Carlson has said he will maintain the modules.
  • audioop/sunau/aifc
    • Audio modules where the formats are still used.
  • base64/quopri/uu
    • All still widely used.
    • ‘codecs’ module does not provide as nice of an API for basicusage.
  • fileinput
    • Useful when having to work with stdin.
  • linecache
    • Used internally in several places.
  • nis
    • Testimonials from people that new installations of NIS are stilloccurring
  • getopt
    • Simpler than optparse.
  • repr
    • Useful as a basis for overriding.
    • Used internally.
  • sched
    • Useful for simulations.
  • symtable/_symtable
    • Docs were written.
  • telnetlib
    • Really handy for quick-and-dirty remote access.
    • Some hardware supports using telnet for configuration andquerying.
  • Tkinter
    • Would prevent IDLE from existing.
    • No GUI toolkit would be available out of the box.

Introducing a new top-level package

It has been suggested that the entire stdlib be placed within its ownpackage. This PEP will not address this issue as it has its owndesign issues (naming, does it deserve special consideration in importsemantics, etc.). Everything within this PEP can easily be handled ifa new top-level package is introduced.

Introducing new packages to contain theme-related modules

During the writing of this PEP it was noticed that certain themesappeared in the stdlib. In the past people have suggested introducingnew packages to help collect modules that share a similar theme (e.g.,audio). An Open Issue was created to suggest some new packages tointroduce.

In the end, though, not enough support could be pulled together towarrant moving forward with the idea. Instead name simplification hasbeen chosen as the guiding force for PEPs to create.

References

[7]
Python-Dev email: “Py3k release schedule worries”(https://mail.python.org/pipermail/python-3000/2006-December/005130.html)
[8]
Python-Dev email: Autoloading?(https://mail.python.org/pipermail/python-dev/2005-October/057244.html)
[9]
2to3 refactoring tool(http://svn.python.org/view/sandbox/trunk/2to3/)
[10]
PyOpenGL(http://pyopengl.sourceforge.net/)
[11] (1,2,3)
Python Imaging Library (PIL)(http://www.pythonware.com/products/pil/)
[12]
Twisted(http://twistedmatrix.com/trac/)
[13]
SGI Press Release:End of General Availability for MIPS IRIX Products – December 2006(http://www.sgi.com/support/mips_irix.html)
[14]
FORMS Library by Mark Overmars(ftp://ftp.cs.ruu.nl/pub/SGI/FORMS)
[15]
appscript(http://appscript.sourceforge.net/)
[16]
_ast module(http://docs.python.org/library/ast.html)
[17]
python-dev email: getting compiler package failures(https://mail.python.org/pipermail/python-3000/2007-May/007615.html)

Copyright

This document has been placed in the public domain.


Source:https://github.com/python/peps/blob/main/peps/pep-3108.rst

Last modified:2025-01-30 01:20:11 GMT


[8]ページ先頭

©2009-2026 Movatter.jp