| PEP: | 3100 |
|---|---|
| Title: | Miscellaneous Python 3.0 Plans |
| Version: | 66726 |
| Last-Modified: | 2008-10-02 05:40:49 -0700 (Thu, 02 Oct 2008) |
| Author: | Brett Cannon <brett at python.org> |
| Status: | Draft |
| Type: | Informational |
| Content-Type: | text/x-rst |
| Created: | 20-Aug-2004 |
| Post-History: |
Contents
This PEP, previously known as PEP 3000, describes smaller scale changes and new features for which no separate PEP is written yet, all targeted for Python 3000.
The list of features included in this document is subject to change and isn't binding on the Python development community; features may be added, removed, and modified at any time. The purpose of this list is to focus our language development effort on changes that are steps to 3.0, and to encourage people to invent ways to smooth the transition.
This document is not a wish-list that anyone can extend. While there are two authors of this PEP, we're just supplying the text; the decisions for which changes are listed in this document are made by Guido van Rossum, who has chosen them as goals for Python 3.0.
Guido's pronouncements on things that will not change in Python 3.0 are recorded in PEP 3099. [43]
A general goal is to reduce feature duplication by removing old ways of doing things. A general principle of the design will be that one obvious way of doing something is enough. [1]
True division becomes default behavior [34] [done]
exec as a statement is not worth it -- make it a function [done]
Add optional declarations for static typing [45] [10] [done]
Support only new-style classes; classic classes will be gone [1] [done]
The softspace attribute of files goes away. [done]
Use except E1, E2, E3 as err: if you want the error variable. [3] [done]
None becomes a keyword [4]; also True and False [done]
... to become a general expression element [16] [done]
as becomes a keyword [5] (starting in 2.6 already) [done]
Have list comprehensions be syntactic sugar for passing an equivalent generator expression to list(); as a consequence the loop variable will no longer be exposed [36] [done]
Comparisons other than == and != between disparate types will raise an exception unless explicitly supported by the type [6] [done]
floats will not be acceptable as arguments in place of ints for operations where floats are inadvertantly accepted (PyArg_ParseTuple() i & l formats)
Remove from ... import * at function scope. [done] This means that functions can always be optimized and support for unoptimized functions can go away.
__init__.py might become optional in sub-packages? __init__.py will still be required for top-level packages.
Cleanup the Py_InitModule() variants {,3,4} (also import and parser APIs)
Cleanup the APIs exported in pythonrun, etc.
Some expressions will require parentheses that didn't in 2.x:
In order to get rid of the confusion between __builtin__ and __builtins__, it was decided to rename __builtin__ (the module) to builtins, and to leave __builtins__ (the sandbox hook) alone. [47] [48] [done]
Attributes on functions of the form func_whatever will be renamed __whatever__ [17] [done]
Set literals and comprehensions [19] [20] [done] {x} means set([x]); {x, y} means set([x, y]). {F(x) for x in S if P(x)} means set(F(x) for x in S if P(x)). NB. {range(x)} means set([range(x)]), NOT set(range(x)). There's no literal for an empty set; use set() (or {1}&{2} :-). There's no frozenset literal; they are too rarely needed.
The __nonzero__ special method will be renamed to __bool__ and have to return a bool. The typeobject slot will be called tp_bool [23] [done]
Dict comprehensions, as first proposed in [35] [done] {K(x): V(x) for x in S if P(x)} means dict((K(x), V(x)) for x in S if P(x)).
To be removed:
String exceptions: use instances of an Exception class [2] [done]
raise Exception, "message": use raise Exception("message") [12] [done]
`x`: use repr(x) [2] [done]
The <> operator: use != instead [3] [done]
The __mod__ and __divmod__ special methods on float. [they should stay] [21]
METH_OLDARGS [done]
WITH_CYCLE_GC [done]
__getslice__, __setslice__, __delslice__ [32]; remove slice opcodes and use slice objects. [done]
__oct__, __hex__: use __index__ in oct() and hex() instead. [done]
__methods__ and __members__ [done]
C APIs (see code): PyFloat_AsString, PyFloat_AsReprString, PyFloat_AsStringEx, PySequence_In, PyEval_EvalFrame, PyEval_CallObject, _PyObject_Del, _PyObject_GC_Del, _PyObject_GC_Track, _PyObject_GC_UnTrack PyString_AsEncodedString, PyString_AsDecodedString PyArg_NoArgs, PyArg_GetInt, intargfunc, intintargfunc
PyImport_ReloadModule ?
To be removed:
To be removed:
apply(): use f(*args, **kw) instead [2] [done]
buffer(): must die (use a bytes() type instead) (?) [2] [done]
callable(): just use hasattr(x, '__call__') (?) [2] [done]
compile(): put in sys (or perhaps in a module of its own) [2]
coerce(): no longer needed [2] [done]
execfile(), reload(): use exec() [2] [done]
reduce(): put in functools, a loop is more readable most of the times [2], [9] [done]
xrange(): use range() instead [1] [See range() above] [done]
subclass Exception instead. [done]
To be removed:
The sets module. [done]
sys.exc_type, sys.exc_values, sys.exc_traceback: not thread-safe; use sys.exc_info() or an attribute of the exception [2] [11] [28] [done]
sys.exc_clear: Python 3's except statements provide the same functionality [24] [46] [28] [done]
array.read, array.write [30]
operator.isCallable : callable() built-in is being removed [29] [50] [done]
operator.sequenceIncludes : redundant thanks to operator.contains [29] [50] [done]
In the thread module, the aquire_lock() and release_lock() aliases for the acquire() and release() methods on lock objects. (Probably also just remove the thread module as a public API, in favor of always using threading.py.)
UserXyz classes, in favour of XyzMixins.
Remove the unreliable empty() and full() methods from Queue.py?
Remove jumpahead() from the random API?
Make the primitive for random be something generating random bytes rather than random floats?
Get rid of Cookie.SerialCookie and Cookie.SmartCookie?
Modify the heapq.heapreplace() API to compare the new value to the top of the heap?
| [1] | (1, 2, 3, 4, 5) PyCon 2003 State of the Union: http://www.python.org/doc/essays/ppt/pycon2003/pycon2003.ppt |
| [2] | (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) Python Regrets: http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.pdf |
| [3] | (1, 2) Python Wiki: http://www.python.org/moin/Python3.0 |
| [4] | python-dev email ("Constancy of None") http://mail.python.org/pipermail/python-dev/2004-July/046294.html |
| [5] | python-dev email (' "as" to be a keyword?') http://mail.python.org/pipermail/python-dev/2004-July/046316.html |
| [6] | python-dev email ("Comparing heterogeneous types") http://mail.python.org/pipermail/python-dev/2004-June/045111.html |
| [7] | python-dev email ("Let's get rid of unbound methods") http://mail.python.org/pipermail/python-dev/2005-January/050625.html |
| [8] | python-dev email ("Fixing _PyEval_SliceIndex so that integer-like objects can be used") http://mail.python.org/pipermail/python-dev/2005-February/051674.html |
| [9] | Guido's blog ("The fate of reduce() in Python 3000") http://www.artima.com/weblogs/viewpost.jsp?thread=98196 |
| [10] | Guido's blog ("Python Optional Typechecking Redux") http://www.artima.com/weblogs/viewpost.jsp?thread=89161 |
| [11] | python-dev email ("anonymous blocks") http://mail.python.org/pipermail/python-dev/2005-April/053060.html |
| [12] | python-dev email ("PEP 8: exception style") http://mail.python.org/pipermail/python-dev/2005-August/055190.html |
| [13] | python-dev email (Remove str.find in 3.0?) http://mail.python.org/pipermail/python-dev/2005-August/055705.html |
| [14] | python-dev email (Replacement for print in Python 3.0) http://mail.python.org/pipermail/python-dev/2005-September/056154.html |
| [15] | python-dev email ("defaultdict") http://mail.python.org/pipermail/python-dev/2006-February/061261.html |
| [16] | python-3000 email http://mail.python.org/pipermail/python-3000/2006-April/000996.html |
| [17] | python-3000 email ("Pronouncement on parameter lists") http://mail.python.org/pipermail/python-3000/2006-April/001175.html |
| [18] | python-3000 email ("More wishful thinking") http://mail.python.org/pipermail/python-3000/2006-April/000810.html |
| [19] | python-3000 email ("sets in P3K?") http://mail.python.org/pipermail/python-3000/2006-April/001286.html |
| [20] | python-3000 email ("sets in P3K?") http://mail.python.org/pipermail/python-3000/2006-May/001666.html |
| [21] | python-3000 email ("bug in modulus?") http://mail.python.org/pipermail/python-3000/2006-May/001735.html |
| [22] | SF patch "sys.id() and sys.intern()" http://www.python.org/sf/1601678 |
| [23] | python-3000 email ("__nonzero__ vs. __bool__") http://mail.python.org/pipermail/python-3000/2006-November/004524.html |
| [24] | python-3000 email ("Pre-peps on raise and except changes") http://mail.python.org/pipermail/python-3000/2007-February/005672.html |
| [25] | python-3000 email ("Py3.0 Library Ideas") http://mail.python.org/pipermail/python-3000/2007-February/005726.html |
| [26] | python-dev email ("Should we do away with unbound methods in Py3k?") http://mail.python.org/pipermail/python-dev/2007-November/075279.html |
| [27] | python-dev email ("Mutable sequence .sort() signature") http://mail.python.org/pipermail/python-dev/2008-February/076818.html |
| [28] | (1, 2, 3) Python docs (sys -- System-specific parameters and functions) http://docs.python.org/library/sys.html |
| [29] | (1, 2) Python docs (operator -- Standard operators as functions) http://docs.python.org/library/operator.html |
| [30] | Python docs (array -- Efficient arrays of numeric values) http://docs.python.org/library/array.html |
| [31] | Python docs (File objects) http://docs.python.org/library/stdtypes.html |
| [32] | Python docs (Additional methods for emulation of sequence types) http://docs.python.org/reference/datamodel.html#additional-methods-for-emulation-of-sequence-types |
| [33] | (1, 2) PEP 4 ("Deprecation of Standard Modules") http://www.python.org/dev/peps/pep-0004 |
| [34] | (1, 2) PEP 238 (Changing the Division Operator) http://www.python.org/dev/peps/pep-0238 |
| [35] | PEP 274 (Dict Comprehensions) http://www.python.org/dev/peps/pep-0274 |
| [36] | PEP 289 ("Generator Expressions") http://www.python.org/dev/peps/pep-0289 |
| [37] | PEP 299 ("Special __main__() function in modules") http://www.python.org/dev/peps/pep-0299 |
| [38] | PEP 308 ("Conditional Expressions") http://www.python.org/dev/peps/pep-0308 |
| [39] | (1, 2) PEP 328 (Imports: Multi-Line and Absolute/Relative) http://www.python.org/dev/peps/pep-0328 |
| [40] | PEP 343 (The "with" Statement) http://www.python.org/dev/peps/pep-0343 |
| [41] | (1, 2) PEP 352 (Required Superclass for Exceptions) http://www.python.org/dev/peps/pep-0352 |
| [42] | PEP 3001 (Process for reviewing and improving standard library modules) http://www.python.org/dev/peps/pep-3001 |
| [43] | PEP 3099 (Things that will Not Change in Python 3000) http://www.python.org/dev/peps/pep-3099 |
| [44] | PEP 3105 (Make print a function) http://www.python.org/dev/peps/pep-3105 |
| [45] | PEP 3107 (Function Annotations) http://www.python.org/dev/peps/pep-3107 |
| [46] | PEP 3110 (Catching Exceptions in Python 3000) http://www.python.org/dev/peps/pep-3110/#semantic-changes |
| [47] | Approach to resolving __builtin__ vs __builtins__ http://mail.python.org/pipermail/python-3000/2007-March/006161.html |
| [48] | New name for __builtins__ http://mail.python.org/pipermail/python-dev/2007-November/075388.html |
| [49] | Patch to remove sys.exitfunc http://www.python.org/sf/1680961 |
| [50] | (1, 2) Remove deprecated functions from operator http://www.python.org/sf/1516309 |
This document has been placed in the public domain.