Size: 547
Comment:
|
Size: 5910
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
This page has been consolidated into PEP 3000; the PEP is more up-to-date and is actively maintained. [[#e 5]] |
|
Line 3: | Line 5: |
* Reduce feature duplication: - string module vs. string methods - xrange() vs range() - int vs. long - 8 bit vs. Unicode strings - map/filter vs. list comprehensions - lambda vs. def * Library reorganization * Return iterators instead of lists - d.keys(), .values(), .items() - range(), zip(), map(), filter() * Consume iterators - min(), max() * Optional static typing? * Support only new-style classes; classic classes will be gone. |
(Another list is at PythonThreeDotOh, but it incorporates items that GvR has never talked about.) |
Line 19: | Line 7: |
== Core Language Changes == * Remove distinction between `int` and `long` types. [[#d 4]] * Make all strings unicode [[#d 4]], and have a separate `bytes` [[#b 2]] type. * Replace all old-style classes. [[#d 4]] * Make the `exec` statement a function (again.) [[#a 1]] * Make the `print` statement a function. (`write(x,y,z), writeln(x,y,z)`) [[#a 1]] * Add a mechanism so that multiple exceptions can be caught using `except E1, E2, E3:`. For instance: {{{ #!python except E1, E2, E3 as err: # Store error variable ... }}} (Added by GvR, suggested by Bram Cohen.) * Add a `with` statement: {{{ #!python with self: .foo = [1, 2, 3] .bar(4, .foo) }}} * Remove {{{`x`}}}. [[#a 1]] * Instead: use `repr(x)`. * Reason: backticks are hard to read in many fonts and can be mangled by typesetting software. * Remove the `<>` operator. * Instead: use `!=`. * Remove the `lambda` statement. [[#a 1]] [[#d 4]] * Instead: use a local function. * Reason: `lambda` supports only one statement. * Remove support for string exceptions. [[#a 1]] * Instead: use a class. * Perhaps have optional declarations for static typing. * One suggestion is to [http://mail.python.org/pipermail/python-dev/2004-February/042795.html use an "as" keyword for this] and for adaptation ([http://www.python.org/peps/pep-0246.html PEP 246]): {{{ #!python # "x as y" means: adapt x to the y protocol def foo (a as int, b as float) as float: a2 = a as float # Same as: adapt(a, float) ... }}} * Make list comprehensions equivalent to passing a generator expression to `list()` * Reason: essentially the same and removes edge-case differences between the two * `as` a keyword [[#g 7]] * Have `True` and `False` be keywords [[#f 6]] * Reason: stop assignment to them * True division becomes default * Remove `__cmp__` (and possibly cmp() ) [[#h 8]] * Reason: TOOWTDI and rich comparisons are another way * Raise exception when comparing two heterogeneous types with operators other than `==` and `!=` * Reason: comparisons do not make sense * Automatically have types compare as not equal when types are heterogeneous [[#i 9]] * Reason: equality does not make sense between heterogeneous types * Exceptions inherit from common base class [[#j 10]] * Reason: forces use of classes as objects raised by exceptions; simplifies implementation == Built-In Changes == * Have `range()`, `zip()`, `dict.keys()`, `dict.items()`, and `dict.values()` return iterators. * Move `compile()`, `intern()` and `id()` to the `sys` module. [[#a 1]] * Change `max()` and `min()` to consume iterators. * Remove `coerce()` as it is obsolete. [[#a 1]] * Remove `dict.iteritems()`, `dict.iterkeys()`, and `dict.itervalues()`. * Instead: use `dict.items()`, `dict.keys()`, and `dict.values()` respectively. * Remove `apply()`. [[#a 1]] * Instead: use `f(*args, **kw)`. * Remove `xrange()`. [[#a 1]] [[#d 4]] * Instead: use `range()`. * Remove `map()` and `filter()`. [[#a 1]] [[#d 4]] * Instead: use list comprehensions. * Remove `reduce()`. [[#a 1]] * Instead: use a loop. * Remove `callable()`. [[#a 1]] * Instead: catch the exception. * Remove `buffer()`. [[#a 1]] [[#b 2]] * Instead: use new `bytes` type. * Remove `raw_input()`. [[#a 1]] * Instead: use `sys.stdin.readline()`. * Remove `input()`. [[#a 1]] * Instead: use `eval(sys.stdin.readline())`. * Remove `execfile()` and `reload()`. [[#a 1]] * Instead: use `exec()`. == Standard Library Changes == * Remove `string` module. [[#c 4]] * Instead: use string methods. * Remove other deprecated modules. [[#c 3]] * Remove `sys.exc_type`. [[#a 1]] * Instead: use `sys.exc_info`. * Reason: it is not thread safe. * Reorganize with more package structure * Reason: too many modules to have in a flat hierarchy == Unresolved Issues == * `L += x` and `L.extend(x)` are equivalent. * Can the parameter order of the `insert` method be changed so the the index parameter is optional and `list.append` may be removed? * Should the `raise x, y` syntax be removed as to favor `raise x(y)`? * Are `repr()` and `str()` both needed? [[#a 1]] * Should `globals()`, `locals()` and `vars()` be removed? [[#a 1]] * Keyword for allowing shadowing of built-ins? * Prevent injecting into another modules global namespace? == References == * [[Anchor(a)]] [1] Python Regrets: http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.pdf * [[Anchor(b)]] [2] PEP 296 -- Adding a bytes Object Type: http://python.org/peps/pep-0296.html * [[Anchor(c)]] [3] PEP 4 -- Deprecation of Standard Modules: http://python.org/peps/pep-0004.html * [[Anchor(d)]] [4] PyCon 2003 State of the Union Address: http://www.python.org/doc/essays/ppt/pycon2003/pycon2003.ppt * [[Anchor(e)]] [5] PEP 3000 -- Python 3.0 Plans: http://python.org/peps/pep-3000.html * [[Anchor(f)]] [6] "Constancy of None" thread -- http://mail.python.org/pipermail/python-dev/2004-July/046294.html * [[Anchor(g)]] [7] " "as" to be a keyword?" thread -- http://mail.python.org/pipermail/python-dev/2004-July/046316.html * [[Anchor(h)]] [8] "lists vs. tuples" thread -- http://mail.python.org/pipermail/python-dev/2003-March/034073.html * [[Anchor(i)]] [9] another email from "lists vs. tuples" thread -- http://mail.python.org/pipermail/python-dev/2003-March/034074.html * [[Anchor(j)]] [10] "Exceptional inheritance patterns" thread -- http://mail.python.org/pipermail/python-dev/2004-August/047114.html |
This page lists features that GvR has mentioned as goals for Python 3.0. This page has been consolidated into PEP 3000; the PEP is more up-to-date and is actively maintained. #e 5
(Another list is at PythonThreeDotOh, but it incorporates items that GvR has never talked about.)
Core Language Changes
Remove distinction between int and long types. #d 4
Make all strings unicode #d 4, and have a separate bytes #b 2 type.
Replace all old-style classes. #d 4
Make the exec statement a function (again.) #a 1
Make the print statement a function. (write(x,y,z), writeln(x,y,z)) #a 1
Add a mechanism so that multiple exceptions can be caught using except E1, E2, E3:. For instance:
(Added by GvR, suggested by Bram Cohen.)Add a with statement:
Remove `x`. #a 1
Instead: use repr(x).
- Reason: backticks are hard to read in many fonts and can be mangled by typesetting software.
Remove the <> operator.
Instead: use !=.
Remove the lambda statement. #a 1 #d 4
- Instead: use a local function.
Reason: lambda supports only one statement.
Remove support for string exceptions. #a 1
- Instead: use a class.
- Perhaps have optional declarations for static typing.
One suggestion is to [http://mail.python.org/pipermail/python-dev/2004-February/042795.html use an "as" keyword for this] and for adaptation ([http://www.python.org/peps/pep-0246.html PEP 246]):
Make list comprehensions equivalent to passing a generator expression to list()
- Reason: essentially the same and removes edge-case differences between the two
as a keyword #g 7
Have True and False be keywords #f 6
- Reason: stop assignment to them
- True division becomes default
Remove __cmp__ (and possibly cmp() ) #h 8
- Reason: TOOWTDI and rich comparisons are another way
Raise exception when comparing two heterogeneous types with operators other than == and !=
- Reason: comparisons do not make sense
Automatically have types compare as not equal when types are heterogeneous #i 9
- Reason: equality does not make sense between heterogeneous types
Exceptions inherit from common base class #j 10
- Reason: forces use of classes as objects raised by exceptions; simplifies implementation
Built-In Changes
Have range(), zip(), dict.keys(), dict.items(), and dict.values() return iterators.
Move compile(), intern() and id() to the sys module. #a 1
Change max() and min() to consume iterators.
Remove coerce() as it is obsolete. #a 1
Remove dict.iteritems(), dict.iterkeys(), and dict.itervalues().
Instead: use dict.items(), dict.keys(), and dict.values() respectively.
Remove apply(). #a 1
Instead: use f(*args, **kw).
Instead: use range().
Remove map() and filter(). #a 1 #d 4
- Instead: use list comprehensions.
Remove reduce(). #a 1
- Instead: use a loop.
Remove callable(). #a 1
- Instead: catch the exception.
Instead: use new bytes type.
Remove raw_input(). #a 1
Instead: use sys.stdin.readline().
Remove input(). #a 1
Instead: use eval(sys.stdin.readline()).
Remove execfile() and reload(). #a 1
Instead: use exec().
Standard Library Changes
Remove string module. #c 4
- Instead: use string methods.
Remove other deprecated modules. #c 3
Remove sys.exc_type. #a 1
Instead: use sys.exc_info.
- Reason: it is not thread safe.
- Reorganize with more package structure
- Reason: too many modules to have in a flat hierarchy
Unresolved Issues
L += x and L.extend(x) are equivalent.
Can the parameter order of the insert method be changed so the the index parameter is optional and list.append may be removed?
Should the raise x, y syntax be removed as to favor raise x(y)?
Are repr() and str() both needed? #a 1
Should globals(), locals() and vars() be removed? #a 1
- Keyword for allowing shadowing of built-ins?
- Prevent injecting into another modules global namespace?
References
Anchor(a) [1] Python Regrets: http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.pdf
Anchor(b) [2] PEP 296 -- Adding a bytes Object Type: http://python.org/peps/pep-0296.html
Anchor(c) [3] PEP 4 -- Deprecation of Standard Modules: http://python.org/peps/pep-0004.html
Anchor(d) [4] PyCon 2003 State of the Union Address: http://www.python.org/doc/essays/ppt/pycon2003/pycon2003.ppt
Anchor(e) [5] PEP 3000 -- Python 3.0 Plans: http://python.org/peps/pep-3000.html
Anchor(f) [6] "Constancy of None" thread -- http://mail.python.org/pipermail/python-dev/2004-July/046294.html
Anchor(g) [7] " "as" to be a keyword?" thread -- http://mail.python.org/pipermail/python-dev/2004-July/046316.html
Anchor(h) [8] "lists vs. tuples" thread -- http://mail.python.org/pipermail/python-dev/2003-March/034073.html
Anchor(i) [9] another email from "lists vs. tuples" thread -- http://mail.python.org/pipermail/python-dev/2003-March/034074.html
Anchor(j) [10] "Exceptional inheritance patterns" thread -- http://mail.python.org/pipermail/python-dev/2004-August/047114.html