python-peps/pep-3000.txt

168 lines
5.2 KiB
Plaintext
Raw Normal View History

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
========
This PEP describes the changes currently envisioned in Python 3.0
(also called Python 3000), a
2004-08-20 08:43:19 -04:00
hypothetical future release of Python that can break backwards
2004-08-20 11:05:39 -04:00
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
=============
* Remove distinction between int and long types. [1]_
* True division becomes default behavior
2004-08-20 08:43:19 -04:00
* 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
2004-08-20 08:43:19 -04:00
* Add optional declarations for static typing
* Support only new-style classes; classic classes will be gone. [1]_
* Add a 'with' statement::
with self:
.foo = [1, 2, 3]
.bar(4, .foo)
* Return iterators instead of lists
2004-08-27 09:16:31 -04:00
- ``dict.keys()``, ``.values()``, ``.items()``
- ``range()``, ``zip()``
2004-08-27 09:16:31 -04:00
2004-08-20 11:05:39 -04:00
* Replace ``print`` by a function: ``write(x,y,z)``,
``writeln(x,y,z)`` [2]_
* 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]_
* ``True`` and ``False`` become keywords [4]_
* ``as`` becomes a keyword [5]_
* 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.
* 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]_
2004-08-20 08:43:19 -04:00
To be removed:
* The ``lambda`` statement: use nested functions [1]_, [9]_
* String exceptions: use instances of an Exception class [2]_
2004-08-20 11:05:39 -04:00
* ```x```: use ``repr(x)`` [2]_
* The ``<>`` operator: use ``!=`` instead [3]_
* Unbound methods [7]_
2004-08-20 08:43:19 -04:00
Built-ins
=========
* Make ``range()`` return an iterator
2004-08-20 11:05:39 -04:00
* Relevant functions should consume iterators (e.g. ``min()``,
``max()``)
* Introduce ``trunc()``, which would call the ``__trunc__()`` method on its
argument; suggested use if for objects like float where calling ``__int__()``
has data loss, but an integral representation is still desired [8]_
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]_
* ``compile()``: put in ``sys`` (or perhaps in a module of its own)
[2]_
* ``coerce()``: no longer needed [2]_
* ``execfile()``, ``reload()``: use ``exec()`` [2]_
* ``input()``: use ``eval(sys.stdin.readline())`` [2]_
* ``intern()``, ``id()``: put in ``sys`` [2]_
* ``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
Standard library
================
* Reorganize the standard library to not be as shallow
2004-08-20 08:43:19 -04:00
To be removed:
2004-08-20 11:05:39 -04:00
* ``string`` and other deprecated modules [1]_
* ``sys.exc_type``: not thread-safe; use ``sys.exc_info`` [2]_
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
.. [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
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: