Differences between revisions 2 and 16 (spanning 14 versions)
Revision 2 as of 2004-08-17 13:17:25
Size: 1182
Comment:
Revision 16 as of 2004-08-22 23:03:04
Size: 3975
Editor: pcp07842301pcs
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
 * Reduce feature duplication:
   * string module vs. string methods
   * xrange() vs range()
   * int vs. long
   * 8 bit vs. Unicode strings
   * map/filter/reduce 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.
 * Remove string exceptions, `x` for repr(x), sys.exc_type, coerce(), other deprecated stuff
 * print as a function -- write(x,y,z), writeln(x,y,z)
(Another list is at PythonThreeDotOh, but it incorporates items that GvR has never talked about.)
Line 21: Line 5:
See the "Python Regrets" talk and other recent presentations by Guido. This will eventually be consolidated into PEP 3000. [[#e 5]]
Line 23: Line 7:
== Rearrangements == == Core Language Changes ==
Line 25: Line 9:
intern(), id(): put in sys  * Remove distinction between `int` and `long` types. [[#a 4]]
 * Make all strings unicode, and have a separate bytes type. [[#a 2]] [[#a 4]]
 * Replace all old-style classes. [[#a 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]]
 * Do something so you can catch multiple exceptions using `except E1, E2, E3:`. Perhaps use `except E1, E2, E3 as err:` if you want the error variable. (Added by GvR, suggested by Bram Cohen.)
 * Add a `with` statement: {{{
with self:
    .foo = [1, 2, 3]
    .bar(4, .foo)
}}}
Line 27: Line 21:
xrange(): make range() return an iterator  * Remove {{{`x`}}}. [[#a 1]]
   Alternatively: use `repr(x)`.
Line 29: Line 24:
buffer(): must die (use bytes, PEP 296)    Reasoning: backticks are hard to read in many fonts and can be mangled by typesetting software.
 * Remove the `lambda` statement. [[#a 1]] [[#a 4]]
   Alternatively: use a local function.
Line 31: Line 28:
raw_input(): use sys.stdin.readline()    Reasoning: `lambda` supports only one statement.
 * Remove support for string exceptions. [[#a 1]]
   Alternatively: 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]): {{{
"x as y" means: adapt x to the y protocol
Line 33: Line 35:
input(): use eval(sys.stdin.readline()) def foo (a as int, b as float) as float:
    a2 = a as float # same as: adapt(a,float)
    ...
}}}
Line 35: Line 40:
callable(): just call it, already == Built-In Changes ==
Line 37: Line 42:
execfile(), reload(): use exec()  * 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.
Line 39: Line 46:
compile(): put in sys  * Remove `dict.iteritems()`, `dict.iterkeys()`, and `dict.itervalues()`.
   Alternatively: use `dict.items()`, `dict.keys()`, and `dict.values()` respectively.
 * Remove `apply()`. [[#a 1]]
   Alternatively: use `f(*args, **kw)`.
 * Remove `xrange()`. [[#a 1]] [[#a 4]]
   Alternatively: use `range()`.
 * Remove `map()` and `filter()`. [[#a 1]] [[#a 4]]
   Alternatively: use list comprehensions.
 * Remove `coerce()` as it is obsolete. [[#a 1]]
 * Remove `reduce()`. [[#a 1]]
   Alternatively: use a loop.
 * Remove `callable()`. [[#a 1]]
   Alternatively: catch the exception.
 * Remove `buffer()`. [[#a 1]] [[#a 2]]
   Alternatively: use new `bytes` type.
 * Remove `raw_input()`. [[#a 1]]
   Alternatively: use `sys.stdin.readline()`.
 * Remove `input()`. [[#a 1]]
   Alternatively: use `eval(sys.stdin.readline())`.
 * Remove `execfile()` and `reload()`. [[#a 1]]
   Alternatively: use `exec()`.
Line 41: Line 68:
exec as a statement is not worth it -- make it a function == Standard Library Changes ==
Line 43: Line 70:
 * Remove `string` module. [[#c 4]]
   Alternatively: use string methods.
 * Remove other deprecated modules. [[#c 3]]
 * Remove `sys.exc_type`. [[#a 1]]
   Alternatively: use `sys.exc_info`.
Line 44: Line 76:
   Reasoning: it is not thread safe.
Line 45: Line 78:
== Unresolved Issues ==

 * `L += x` and `L.extend(x)` are equivalent.
 * Can the order of parameter of the `insert` method be changed so the the index parameter is optional and `list.append` can be removed?
 * What is the status of the `<>` operator? Answer: it's dead. (GvR)

== 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

This page lists features that GvR has mentioned as goals for Python 3.0.

(Another list is at PythonThreeDotOh, but it incorporates items that GvR has never talked about.)

This will eventually be consolidated into PEP 3000. #e 5

Core Language Changes

  • Remove distinction between int and long types. #a 4

  • Make all strings unicode, and have a separate bytes type. #a 2 #a 4

  • Replace all old-style classes. #a 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

  • Do something so you can catch multiple exceptions using except E1, E2, E3:. Perhaps use except E1, E2, E3 as err: if you want the error variable. (Added by GvR, suggested by Bram Cohen.)

  • Add a with statement:

    with self:
        .foo = [1, 2, 3]
        .bar(4, .foo)
  • Remove `x`. #a 1

    • Alternatively: use repr(x). Reasoning: backticks are hard to read in many fonts and can be mangled by typesetting software.

  • Remove the lambda statement. #a 1 #a 4

    • Alternatively: use a local function.

      Reasoning: lambda supports only one statement.

  • Remove support for string exceptions. #a 1

    • Alternatively: use a class.
  • Perhaps have optional declarations for static typing.

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 dict.iteritems(), dict.iterkeys(), and dict.itervalues().

    • Alternatively: use dict.items(), dict.keys(), and dict.values() respectively.

  • Remove apply(). #a 1

    • Alternatively: use f(*args, **kw).

  • Remove xrange(). #a 1 #a 4

    • Alternatively: use range().

  • Remove map() and filter(). #a 1 #a 4

    • Alternatively: use list comprehensions.
  • Remove coerce() as it is obsolete. #a 1

  • Remove reduce(). #a 1

    • Alternatively: use a loop.
  • Remove callable(). #a 1

    • Alternatively: catch the exception.
  • Remove buffer(). #a 1 #a 2

    • Alternatively: use new bytes type.

  • Remove raw_input(). #a 1

    • Alternatively: use sys.stdin.readline().

  • Remove input(). #a 1

    • Alternatively: use eval(sys.stdin.readline()).

  • Remove execfile() and reload(). #a 1

    • Alternatively: use exec().

Standard Library Changes

  • Remove string module. #c 4

    • Alternatively: use string methods.
  • Remove other deprecated modules. #c 3

  • Remove sys.exc_type. #a 1

    • Alternatively: use sys.exc_info. Reasoning: it is not thread safe.

Unresolved Issues

  • L += x and L.extend(x) are equivalent.

  • Can the order of parameter of the insert method be changed so the the index parameter is optional and list.append can be removed?

  • What is the status of the <> operator? Answer: it's dead. (GvR)

References

Python3.0 (last edited 2011-04-08 16:42:51 by ip-109-90-196-137)

Unable to edit the page? See the FrontPage for instructions.