[python-advocacy] Python 3000 question for PR
David Goodger
goodger at python.org
Wed Dec 5 22:43:05 CET 2007
Hi Daniel,
Sorry for not replying to your initial request. So much to do, so
little time!
It's hard to express what the top 3 benefits of Python 3000 are,
because I think the main benefits are long-term infrastructure
improvements that wouldn't easily be perceived as benefits by most
people. But here goes:
1. Remove cruft (flaws, warts, deprecated features) accumulated since
1990, to build a strong foundation for future innovation.
2. Improve and streamline the language/syntax in subtle ways to improve
usability and remove ambiguity.
3. Change text data to be Unicode throughout, elevating text to a
distinct data type and allowing for easier and more universal
internationalization and localization.
(Others on-list: please feel free to correct any mistakes or omissions
in the following.)
Here's my attempt at explaining this in a way that tech journalists
may understand:
Python version 3 (a.k.a. Python 3000) is not a new language; it's a
cleanup of Python 2.X, a renovation of Python's foundation. Along
with incremental changes from Python 2.X, Python 3 will fix several
long-standing "warts" or design flaws (many from the early days of
1990-1991) and get rid of deprecated features, as well as introduce
some new features.
Python 3 is not backwards-compatible with Python 2.X. Some
incompatible changes are being introduced in order to improve the
foundations of Python going forward, anticipating and facilitating
future innovation.
A conversion tool will be included in Python 2.6 to automatically
convert most Python 2.X code to be compatible with 3, and it will warn
about code that can't be converted. Python 2.6 will also have a
Python 3.0 compatibility-warning mode.
There will continue to be Python 2.X releases. Python 2.7 is already
planned, and further 2.X releases will happen if there's enough demand
(and a sufficient supply of interested developers). There is no
danger of Python 2.X code becoming obsolete any time soon. Many of
the features that will be introduced in Python 3.X will be back-ported
to Python 2.X, however most innovation will take place in Python 3.X
first. End-users (developers using Python) are not expected to start
using Python 3.0 immediately, but should consider switching and
migrating their code once Python 3 matures (probably by Python 3.1 or
3.2).
Python 3 is a mix of innovation and conservatism. It's the right to
do for the future of Python.
Fixes lots of long-standing warts:
- Dividing any two numbers (integer or float) returns a float if
necessary. Previously, 3/4 returned 0; if you wanted 0.75, you'd
have to say 3/4.0 or 4.0/2. If you want truncating integer division
in Python 3, you say 3//4 (two slashes).
- "print" and "exec" are now a functions, no longer statements. As
statements, "print" and "exec" were always oddballs and didn't
require syntax support.
- Comparisons of types have been tightened up
- The "input" function has been replaced with a simpler, safe
implementation, formerly "raw_input". The old "input" function was
dangerous, because it evaluated arbitrary user input, a potential
security hole.
- The old dichotomy of small integers ("int") and large integers
("long") has been removed. Values will transparently convert.
- Module imports are now absolute by default, although relative
imports can be specified. This allows
- Remove support for "classic" (old-style) classes; new-style classes
become the default.
- Several syntax improvements to remove ambiguity: "except ... as
...", "raise Exception(...)", "repr(...)" instead of "`...`", "!="
instead of "<>", etc.
New features:
- All text strings ("str" type) are now Unicode, so text encodings
have to be explicitly specified. There is no longer an 8-bit
sometimes-text, sometimes-binary string data type. A new "bytes"
array type has been added for raw binary data. This reduces some
internationalization incompatibilities, where text characters
(letters, digits, punctuation, etc.) and raw binary bytes could be
mixed and mistaken for each other.
- A new platform-independent low-level input/output (I/O) library is
being added to support text strings and byte arrays.
- The "dictionary" core data structure (used for data storage and
lookups, indexed by arbitrary keys) will acquire "views", a
mechanism for efficient access.
- Function annotations will allow for (but do not require!) static
type declarations, among other applications. Such applications will
be implemented by 3rd-party packages, not part of core Python (at
least at first).
- Miscellaneous features: keyword-only parameters, set literals, set
comprehensions, abstract base classes, improved text formatting.
--
David Goodger <http://python.net/~goodger>
More information about the Advocacy
mailing list