2004-08-20 08:43:19 -04:00
|
|
|
|
PEP: 3000
|
|
|
|
|
Title: Python 3.0 Plans
|
|
|
|
|
Version: $Revision$
|
|
|
|
|
Last-Modified: $Date$
|
2004-08-20 11:05:39 -04:00
|
|
|
|
Author: A.M. Kuchling <amk@amk.ca>,
|
2004-08-20 08:43:19 -04:00
|
|
|
|
Brett Cannon <drifty@alum.berkeley.edu>
|
|
|
|
|
Status: Draft
|
|
|
|
|
Type: Informational
|
|
|
|
|
Content-Type: text/x-rst
|
|
|
|
|
Created: 20-Aug-2004
|
2004-08-20 11:05:39 -04:00
|
|
|
|
Post-History:
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Abstract
|
|
|
|
|
========
|
|
|
|
|
|
2004-08-27 01:24:03 -04:00
|
|
|
|
This PEP describes the changes currently envisioned in Python 3.0
|
2005-03-15 14:43:34 -05:00
|
|
|
|
(also called Python 3000), a hypothetical future release of Python that
|
|
|
|
|
can break backwards compatibility with the existing body of Python code.
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
|
|
|
|
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
|
2004-08-20 11:05:39 -04:00
|
|
|
|
Guido van Rossum, who has chosen them as goals for Python 3.0.
|
|
|
|
|
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
|
|
|
|
General goals
|
|
|
|
|
=============
|
|
|
|
|
|
|
|
|
|
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]_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Core language
|
|
|
|
|
=============
|
|
|
|
|
|
2005-04-28 14:57:40 -04:00
|
|
|
|
* Remove distinction between int and long types [1]_
|
|
|
|
|
* True division becomes default behavior [10]_
|
|
|
|
|
* Make all strings be Unicode, and have a separate bytes() type [1]_
|
2004-08-20 11:05:39 -04:00
|
|
|
|
* ``exec`` as a statement is not worth it -- make it a function
|
2005-04-28 14:57:40 -04:00
|
|
|
|
* Add optional declarations for static typing [11]_
|
|
|
|
|
* Support only new-style classes; classic classes will be gone [1]_
|
|
|
|
|
* Return iterators instead of lists where appropriate for atomic type methods
|
|
|
|
|
(e.g. ``dict.keys()``, ``dict.values()``, ``dict.items()``, etc.)
|
2005-12-14 23:55:32 -05:00
|
|
|
|
(Do we keep iter*() methods or remove them? I vote remove. -- nn)
|
2005-09-07 20:26:20 -04:00
|
|
|
|
* Replace ``print`` by a function [16]_
|
2004-08-20 11:05:39 -04:00
|
|
|
|
* Do something so you can catch multiple exceptions using ``except E1,
|
|
|
|
|
E2, E3:``. Maybe use ``except E1, E2, E3 as err:`` if you want the
|
|
|
|
|
error variable? [3]_
|
2005-12-14 23:55:32 -05:00
|
|
|
|
* ``None``, ``True`` and ``False`` become keywords [4]_
|
2004-08-27 01:24:03 -04:00
|
|
|
|
* ``as`` becomes a keyword [5]_
|
2004-08-27 14:43:32 -04:00
|
|
|
|
* Have list comprehensions be syntactic sugar for passing an
|
2004-09-02 15:10:13 -04:00
|
|
|
|
equivalent generator expression to ``list()``; as a consequence the
|
2005-04-28 14:57:40 -04:00
|
|
|
|
loop variable will no longer be exposed [12]_
|
2004-08-27 14:43:32 -04:00
|
|
|
|
* Comparisons other than ``==`` and ``!=`` between disparate types
|
2004-12-11 13:06:27 -05:00
|
|
|
|
will raise an exception unless explicitly supported by the type [6]_
|
2005-04-28 16:04:32 -04:00
|
|
|
|
* Exceptions will grow an attribute to store the traceback [13]_
|
2005-12-14 23:55:32 -05:00
|
|
|
|
* floats will not be acceptable as arguments in place of ints for operations
|
|
|
|
|
where floats are inadvertantly accepted (PyArg_ParseTuple() i & l formats)
|
|
|
|
|
* Imports will be absolute by default.
|
|
|
|
|
Relative imports must be explicitly specified [19]_
|
|
|
|
|
* __init__.py will be optional in sub-packages. __init__.py will still
|
|
|
|
|
be required for top-level packages.
|
2006-02-18 15:32:56 -05:00
|
|
|
|
* Cleanup the Py_InitModule() variants {,3,4}
|
|
|
|
|
* Cleanup the APIs exported in pythonrun, etc.
|
|
|
|
|
* Fix (or remove) {}.setdefault() [21]_
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
|
|
|
|
To be removed:
|
|
|
|
|
|
2005-03-10 19:56:22 -05:00
|
|
|
|
* String exceptions: use instances of an Exception class [2]_
|
2005-08-06 19:13:59 -04:00
|
|
|
|
* ``raise Exception, "message"``: use ``raise Exception("message")`` [14]_
|
2004-08-20 11:05:39 -04:00
|
|
|
|
* ```x```: use ``repr(x)`` [2]_
|
2005-03-10 19:56:22 -05:00
|
|
|
|
* The ``<>`` operator: use ``!=`` instead [3]_
|
2005-01-21 23:39:23 -05:00
|
|
|
|
* Unbound methods [7]_
|
2005-12-14 23:55:32 -05:00
|
|
|
|
* METH_OLDARGS
|
|
|
|
|
* __getslice__, __setslice__, __delslice__ [17]_
|
|
|
|
|
* 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
|
2006-01-03 03:22:57 -05:00
|
|
|
|
PyString_AsEncodedString, PyString_AsDecodedString
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
2006-01-03 03:22:57 -05:00
|
|
|
|
typedefs: intargfunc, intintargfunc
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
2005-08-27 14:27:33 -04:00
|
|
|
|
Built-in Namespace
|
|
|
|
|
==================
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
2005-04-28 14:57:40 -04:00
|
|
|
|
* Make built-ins return an iterator where appropriate (e.g. ``range()``,
|
|
|
|
|
``zip()``, etc.)
|
2004-08-20 11:05:39 -04:00
|
|
|
|
* Relevant functions should consume iterators (e.g. ``min()``,
|
|
|
|
|
``max()``)
|
2005-03-05 14:38:42 -05:00
|
|
|
|
* Introduce ``trunc()``, which would call the ``__trunc__()`` method on its
|
2005-04-28 14:57:40 -04:00
|
|
|
|
argument; suggested use is for objects like float where calling ``__int__()``
|
2005-03-05 14:38:42 -05:00
|
|
|
|
has data loss, but an integral representation is still desired [8]_
|
2005-12-14 23:55:32 -05:00
|
|
|
|
* Exception hierarchy changes [20]_
|
2004-08-20 11:05:39 -04:00
|
|
|
|
|
2004-08-20 08:43:19 -04:00
|
|
|
|
To be removed:
|
|
|
|
|
|
2004-08-20 11:05:39 -04:00
|
|
|
|
* ``apply()``: use ``f(*args, **kw)`` instead [2]_
|
|
|
|
|
* ``buffer()``: must die (use a bytes() type instead) [2]_
|
|
|
|
|
* ``callable()``: just call the object and catch the exception [2]_
|
2005-03-14 23:06:02 -05:00
|
|
|
|
* ``compile()``: put in ``sys`` (or perhaps in a module of its own) [2]_
|
2004-08-20 11:05:39 -04:00
|
|
|
|
* ``coerce()``: no longer needed [2]_
|
|
|
|
|
* ``execfile()``, ``reload()``: use ``exec()`` [2]_
|
|
|
|
|
* ``input()``: use ``eval(sys.stdin.readline())`` [2]_
|
|
|
|
|
* ``intern()``, ``id()``: put in ``sys`` [2]_
|
2005-03-10 19:56:22 -05:00
|
|
|
|
* ``map()``, ``filter()``: use list comprehensions instead [1]_, [9]_
|
|
|
|
|
* ``reduce()``: write a loop instead [2]_, [9]_
|
2004-08-20 11:05:39 -04:00
|
|
|
|
* ``raw_input()``: use ``sys.stdin.readline()`` [2]_
|
|
|
|
|
* ``xrange()``: use ``range()`` instead [1]_
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
|
|
|
|
|
2005-08-27 14:27:33 -04:00
|
|
|
|
Atomic Types
|
|
|
|
|
============
|
|
|
|
|
|
|
|
|
|
To be removed:
|
|
|
|
|
|
|
|
|
|
* ``basestring.find()`` and ``basestring.rfind()``; use ``basestring.index()``
|
|
|
|
|
or ``basestring.rindex()`` in a try/except block [15]_
|
2005-12-14 23:55:32 -05:00
|
|
|
|
* ``file.xreadlines()`` method [17]_
|
2006-02-19 02:10:16 -05:00
|
|
|
|
* ``dict.setdefault()`` [22]_
|
2005-08-27 14:27:33 -04:00
|
|
|
|
|
|
|
|
|
|
2004-08-20 08:43:19 -04:00
|
|
|
|
Standard library
|
|
|
|
|
================
|
|
|
|
|
|
2004-08-27 14:43:32 -04:00
|
|
|
|
* Reorganize the standard library to not be as shallow
|
2005-12-14 23:55:32 -05:00
|
|
|
|
* Move test code to where it belongs, there will be no more test() functions
|
|
|
|
|
in the standard library
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
|
|
|
|
To be removed:
|
|
|
|
|
|
2005-12-14 23:55:32 -05:00
|
|
|
|
* Deprecated modules, methods, parameters, attributes, etc. [1]_ [17]_ [18]_
|
|
|
|
|
There may be other modules, the most common are listed below.
|
|
|
|
|
|
|
|
|
|
stdlib modules to be removed (see docstrings and comments in the source):
|
|
|
|
|
* ``macfs``, ``new``, ``reconvert``, ``stringold``, ``xmllib``
|
|
|
|
|
* ``pcre``, ``pypcre``, ``strop``
|
|
|
|
|
stdlib modules to be removed (see PEP 4): [18]_
|
|
|
|
|
* ``posixfile``, ``pre``, ``regsub``, ``rfc822``,
|
|
|
|
|
* ``statcache``, ``string``, ``TERMIOS``
|
|
|
|
|
* ``mimetools``, ``MimeWriter``, ``mimify``,
|
|
|
|
|
* ``mpz``, ``rgbimage``
|
|
|
|
|
* Everything in lib-old: [18]_
|
|
|
|
|
* Para.py, addpack.py, cmp.py, cmpcache.py, codehack.py,
|
|
|
|
|
* dircmp.py, dump.py, find.py, fmt.py, grep.py, lockfile.py,
|
|
|
|
|
* newdir.py, ni.py, packmail.py, poly.py, rand.py, statcache.py,
|
|
|
|
|
* tb.py, tzparse.py, util.py, whatsound.py, whrandom.py, zmod.py
|
|
|
|
|
|
|
|
|
|
* ``sys.exitfunc``: use atexit module instead [17]_
|
|
|
|
|
* ``sys.exc_type``, ``sys.exc_values``, ``sys.exc_traceback``:
|
|
|
|
|
not thread-safe; use ``sys.exc_info()`` or an attribute
|
|
|
|
|
of the exception [2]_ [13]_ [17]_
|
|
|
|
|
* ``array.read``, ``array.write`` [17]_
|
|
|
|
|
* ``operator.isCallable``, ``operator.sequenceIncludes`` [17]_
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
|
|
|
|
References
|
|
|
|
|
==========
|
|
|
|
|
|
2004-08-20 11:05:39 -04:00
|
|
|
|
.. [1] PyCon 2003 State of the Union:
|
2004-08-20 08:43:19 -04:00
|
|
|
|
http://www.python.org/doc/essays/ppt/pycon2003/pycon2003.ppt
|
|
|
|
|
|
2004-08-20 11:05:39 -04:00
|
|
|
|
.. [2] Python Regrets:
|
2004-08-20 08:43:19 -04:00
|
|
|
|
http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.pdf
|
|
|
|
|
|
2004-08-20 11:05:39 -04:00
|
|
|
|
.. [3] Python Wiki:
|
2004-08-20 08:43:19 -04:00
|
|
|
|
http://www.python.org/moin/Python3.0
|
|
|
|
|
|
2004-08-27 01:24:03 -04:00
|
|
|
|
.. [4] python-dev email ("Constancy of None")
|
|
|
|
|
http://mail.python.org/pipermail/python-dev/2004-July/046294.html
|
|
|
|
|
|
2004-12-11 02:54:17 -05:00
|
|
|
|
.. [5] python-dev email (' "as" to be a keyword?')
|
2004-08-27 01:24:03 -04:00
|
|
|
|
http://mail.python.org/pipermail/python-dev/2004-July/046316.html
|
|
|
|
|
|
2004-12-11 02:54:17 -05:00
|
|
|
|
.. [6] python-dev email ("Comparing heterogeneous types")
|
|
|
|
|
http://mail.python.org/pipermail/python-dev/2004-June/045111.html
|
|
|
|
|
|
2005-01-21 23:39:23 -05:00
|
|
|
|
.. [7] python-dev email ("Let's get rid of unbound methods")
|
|
|
|
|
http://mail.python.org/pipermail/python-dev/2005-January/050625.html
|
|
|
|
|
|
2005-03-14 23:06:02 -05:00
|
|
|
|
.. [8] python-dev email ("Fixing _PyEval_SliceIndex so that integer-like
|
2005-03-05 14:38:42 -05:00
|
|
|
|
objects can be used")
|
|
|
|
|
http://mail.python.org/pipermail/python-dev/2005-February/051674.html
|
|
|
|
|
|
2005-03-10 19:56:22 -05:00
|
|
|
|
.. [9] Guido's blog ("The fate of reduce() in Python 3000")
|
|
|
|
|
http://www.artima.com/weblogs/viewpost.jsp?thread=98196
|
|
|
|
|
|
2005-04-28 14:57:40 -04:00
|
|
|
|
.. [10] PEP 238 ("Changing the Division Operator")
|
|
|
|
|
http://www.python.org/peps/pep-0238.html
|
|
|
|
|
|
|
|
|
|
.. [11] Guido's blog ("Python Optional Typechecking Redux")
|
|
|
|
|
http://www.artima.com/weblogs/viewpost.jsp?thread=89161
|
|
|
|
|
|
|
|
|
|
.. [12] PEP 289 ("Generator Expressions")
|
|
|
|
|
http://www.python.org/peps/pep-0289.html
|
|
|
|
|
|
2005-04-28 16:04:32 -04:00
|
|
|
|
.. [13] python-dev email ("anonymous blocks")
|
|
|
|
|
http://mail.python.org/pipermail/python-dev/2005-April/053060.html
|
|
|
|
|
|
2005-08-06 19:13:59 -04:00
|
|
|
|
.. [14] python-dev email ("PEP 8: exception style")
|
2005-08-27 14:27:33 -04:00
|
|
|
|
http://mail.python.org/pipermail/python-dev/2005-August/055190.html
|
|
|
|
|
|
|
|
|
|
.. [15] python-dev email (Remove str.find in 3.0?)
|
|
|
|
|
http://mail.python.org/pipermail/python-dev/2005-August/055705.html
|
2005-08-06 19:13:59 -04:00
|
|
|
|
|
2005-09-07 20:26:20 -04:00
|
|
|
|
.. [16] python-dev email (Replacement for print in Python 3.0)
|
|
|
|
|
http://mail.python.org/pipermail/python-dev/2005-September/056154.html
|
|
|
|
|
|
2005-12-14 23:55:32 -05:00
|
|
|
|
.. [17] Python docs
|
|
|
|
|
http://docs.python.org/ref/sequence-methods.html
|
|
|
|
|
http://docs.python.org/lib/module-sys.html
|
|
|
|
|
http://docs.python.org/lib/module-operator.html
|
|
|
|
|
http://docs.python.org/lib/module-array.html
|
|
|
|
|
http://docs.python.org/lib/bltin-file-objects.html
|
|
|
|
|
|
|
|
|
|
.. [18] PEP 4 ("Deprecation of Standard Modules")
|
|
|
|
|
http://www.python.org/peps/pep-0004.html
|
|
|
|
|
|
|
|
|
|
.. [19] PEP 328 ("Imports: Multi-Line and Absolute/Relative")
|
|
|
|
|
http://www.python.org/peps/pep-0328.html
|
|
|
|
|
|
|
|
|
|
.. [20] PEP 352 ("Required Superclass for Exceptions")
|
|
|
|
|
http://www.python.org/peps/pep-0352.html
|
2004-08-20 08:43:19 -04:00
|
|
|
|
|
2006-02-18 15:32:56 -05:00
|
|
|
|
.. [21] python-dev email
|
|
|
|
|
http://mail.python.org/pipermail/python-dev/2006-February/061169.html
|
|
|
|
|
|
2006-02-19 02:10:16 -05:00
|
|
|
|
.. [22] python-dev email ("defaultdict")
|
|
|
|
|
http://mail.python.org/pipermail/python-dev/2006-February/061261.html
|
|
|
|
|
|
2004-08-20 08:43:19 -04:00
|
|
|
|
Copyright
|
|
|
|
|
=========
|
|
|
|
|
|
|
|
|
|
This document has been placed in the public domain.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
..
|
|
|
|
|
Local Variables:
|
|
|
|
|
mode: indented-text
|
|
|
|
|
indent-tabs-mode: nil
|
|
|
|
|
sentence-end-double-space: t
|
|
|
|
|
fill-column: 70
|
|
|
|
|
End:
|