blob: a9ab26056c588ae4b0556e0201e72dca0cb61522 [file] [log] [blame]
Łukasz Langa1e5d33e2020-12-07 15:02:38 +01001This is Python version 3.9.1
2============================
Guido van Rossum91447632000-04-11 17:11:09 +00003
Łukasz Langa1bf75782020-05-19 02:31:31 +02004.. image:: https://travis-ci.org/python/cpython.svg?branch=3.9
Victor Stinnerc9b62b42017-02-13 16:57:30 +01005 :alt: CPython build status on Travis CI
6 :target: https://travis-ci.org/python/cpython
7
Steve Dower6a263cf2019-12-16 11:15:08 -08008.. image:: https://github.com/python/cpython/workflows/Tests/badge.svg
9 :alt: CPython build status on GitHub Actions
10 :target: https://github.com/python/cpython/actions
11
Łukasz Langa1bf75782020-05-19 02:31:31 +020012.. image:: https://dev.azure.com/python/cpython/_apis/build/status/Azure%20Pipelines%20CI?branchName=3.9
Steve Dower680d26e2018-09-24 08:04:33 -040013 :alt: CPython build status on Azure DevOps
Łukasz Langa1bf75782020-05-19 02:31:31 +020014 :target: https://dev.azure.com/python/cpython/_build/latest?definitionId=4&branchName=3.9
Steve Dower757b73c2018-08-31 08:11:35 -070015
Łukasz Langa1bf75782020-05-19 02:31:31 +020016.. image:: https://codecov.io/gh/python/cpython/branch/3.9/graph/badge.svg
Victor Stinnerc9b62b42017-02-13 16:57:30 +010017 :alt: CPython code coverage on Codecov
18 :target: https://codecov.io/gh/python/cpython
19
Mariattab57eea12018-06-29 13:43:45 -070020.. image:: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
21 :alt: Python Zulip chat
22 :target: https://python.zulipchat.com
Steve Dower757b73c2018-08-31 08:11:35 -070023
Mariattab57eea12018-06-29 13:43:45 -070024
Benjamin Peterson946b29e2020-01-02 18:56:34 -080025Copyright (c) 2001-2020 Python Software Foundation. All rights reserved.
Guido van Rossum4405cf32007-08-30 17:16:55 +000026
Zachary Wared50f1882017-02-13 22:01:03 -060027See the end of this file for further copyright and license information.
28
INADA Naoki7c8b3fa2017-02-28 16:26:58 +090029.. contents::
30
Mariattae32ec932017-02-25 08:59:26 -080031General Information
32-------------------
33
34- Website: https://www.python.org
35- Source code: https://github.com/python/cpython
36- Issue tracker: https://bugs.python.org
37- Documentation: https://docs.python.org
Lisa Hewus Fresh384899d2017-08-30 09:37:43 -070038- Developer's Guide: https://devguide.python.org/
Mariattae32ec932017-02-25 08:59:26 -080039
Nick Coghlan1b3d88e2017-02-18 12:01:47 +053040Contributing to CPython
41-----------------------
42
43For more complete instructions on contributing to CPython development,
44see the `Developer Guide`_.
45
Lisa Hewus Fresh384899d2017-08-30 09:37:43 -070046.. _Developer Guide: https://devguide.python.org/
Guido van Rossum1c896e32007-08-29 23:03:30 +000047
Ned Batchelder3cdbd682017-02-13 12:05:47 -050048Using Python
49------------
50
51Installable Python kits, and information about using Python, are available at
52`python.org`_.
53
54.. _python.org: https://www.python.org/
55
Benjamin Peterson1da43e52009-06-26 13:21:52 +000056Build Instructions
57------------------
Guido van Rossum3ff96dd1996-07-30 18:05:04 +000058
Paul Schreiberc0866852017-02-20 08:08:59 -050059On Unix, Linux, BSD, macOS, and Cygwin::
Benjamin Peterson1da43e52009-06-26 13:21:52 +000060
61 ./configure
62 make
63 make test
64 sudo make install
65
Suriyaa ✌️️7e3fb402019-01-02 02:57:42 +010066This will install Python as ``python3``.
Benjamin Peterson1da43e52009-06-26 13:21:52 +000067
Zachary Wared50f1882017-02-13 22:01:03 -060068You can pass many options to the configure script; run ``./configure --help``
Ned Deily19d68422019-10-14 08:16:10 -040069to find out more. On macOS case-insensitive file systems and on Cygwin,
70the executable is called ``python.exe``; elsewhere it's just ``python``.
Benjamin Peterson1da43e52009-06-26 13:21:52 +000071
Ned Deily19d68422019-10-14 08:16:10 -040072Building a complete Python installation requires the use of various
73additional third-party libraries, depending on your build platform and
74configure options. Not all standard library modules are buildable or
75useable on all platforms. Refer to the
76`Install dependencies <https://devguide.python.org/setup/#install-dependencies>`_
77section of the `Developer Guide`_ for current detailed information on
78dependencies for various Linux distributions and macOS.
atg7000ee994d72018-06-07 19:33:20 -070079
Ned Deily19d68422019-10-14 08:16:10 -040080On macOS, there are additional configure and build options related
81to macOS framework and universal builds. Refer to `Mac/README.rst
Łukasz Langa1bf75782020-05-19 02:31:31 +020082<https://github.com/python/cpython/blob/3.9/Mac/README.rst>`_.
Benjamin Peterson1da43e52009-06-26 13:21:52 +000083
Zachary Wared50f1882017-02-13 22:01:03 -060084On Windows, see `PCbuild/readme.txt
Łukasz Langa1bf75782020-05-19 02:31:31 +020085<https://github.com/python/cpython/blob/3.9/PCbuild/readme.txt>`_.
Benjamin Peterson1da43e52009-06-26 13:21:52 +000086
Larry Hastingsf92f6c82015-09-12 17:28:39 +010087If you wish, you can create a subdirectory and invoke configure from there.
Victor Stinnerd783b012017-02-11 02:21:38 +010088For example::
Benjamin Peterson1da43e52009-06-26 13:21:52 +000089
90 mkdir debug
91 cd debug
92 ../configure --with-pydebug
93 make
94 make test
95
Zachary Wared50f1882017-02-13 22:01:03 -060096(This will fail if you *also* built at the top-level directory. You should do
Hossein Pourbozorg5f2b3b02019-05-02 12:47:55 +043097a ``make clean`` at the top-level first.)
Benjamin Peterson1da43e52009-06-26 13:21:52 +000098
Zachary Wared50f1882017-02-13 22:01:03 -060099To get an optimized build of Python, ``configure --enable-optimizations``
100before you run ``make``. This sets the default make targets up to enable
101Profile Guided Optimization (PGO) and may be used to auto-enable Link Time
102Optimization (LTO) on some platforms. For more details, see the sections
103below.
Brett Cannon7188a3e2015-09-18 15:13:44 -0700104
Brett Cannon7188a3e2015-09-18 15:13:44 -0700105Profile Guided Optimization
Evan Klitzke6db764a2017-02-27 22:32:07 -0800106^^^^^^^^^^^^^^^^^^^^^^^^^^^
Brett Cannon7188a3e2015-09-18 15:13:44 -0700107
Gregory P. Smithb87c1c92018-04-19 08:58:17 -0700108PGO takes advantage of recent versions of the GCC or Clang compilers. If used,
Gregory P. Smith93f9a8a2018-05-16 10:34:47 -0500109either via ``configure --enable-optimizations`` or by manually running
110``make profile-opt`` regardless of configure flags, the optimized build
111process will perform the following steps:
Brett Cannon7188a3e2015-09-18 15:13:44 -0700112
Gregory P. Smith93f9a8a2018-05-16 10:34:47 -0500113The entire Python directory is cleaned of temporary files that may have
114resulted from a previous compilation.
Brett Cannon7188a3e2015-09-18 15:13:44 -0700115
Gregory P. Smith93f9a8a2018-05-16 10:34:47 -0500116An instrumented version of the interpreter is built, using suitable compiler
117flags for each flavour. Note that this is just an intermediary step. The
118binary resulting from this step is not good for real life workloads as it has
119profiling instructions embedded inside.
Brett Cannon7188a3e2015-09-18 15:13:44 -0700120
Gregory P. Smith93f9a8a2018-05-16 10:34:47 -0500121After the instrumented interpreter is built, the Makefile will run a training
122workload. This is necessary in order to profile the interpreter execution.
123Note also that any output, both stdout and stderr, that may appear at this step
124is suppressed.
Brett Cannon7188a3e2015-09-18 15:13:44 -0700125
Gregory P. Smith93f9a8a2018-05-16 10:34:47 -0500126The final step is to build the actual interpreter, using the information
127collected from the instrumented one. The end result will be a Python binary
128that is optimized; suitable for distribution or production installation.
Brett Cannon7188a3e2015-09-18 15:13:44 -0700129
Benjamin Peterson1da43e52009-06-26 13:21:52 +0000130
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)014d52f2016-09-08 18:33:00 +0000131Link Time Optimization
Evan Klitzke6db764a2017-02-27 22:32:07 -0800132^^^^^^^^^^^^^^^^^^^^^^
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)014d52f2016-09-08 18:33:00 +0000133
Zachary Wared50f1882017-02-13 22:01:03 -0600134Enabled via configure's ``--with-lto`` flag. LTO takes advantage of the
135ability of recent compiler toolchains to optimize across the otherwise
136arbitrary ``.o`` file boundary when building final executables or shared
137libraries for additional performance gains.
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)014d52f2016-09-08 18:33:00 +0000138
139
Benjamin Peterson1da43e52009-06-26 13:21:52 +0000140What's New
141----------
142
Zachary Wared50f1882017-02-13 22:01:03 -0600143We have a comprehensive overview of the changes in the `What's New in Python
Łukasz Langa9ab2fb12019-06-04 22:12:32 +02001443.9 <https://docs.python.org/3.9/whatsnew/3.9.html>`_ document. For a more
Zachary Wared50f1882017-02-13 22:01:03 -0600145detailed change log, read `Misc/NEWS
Łukasz Langa1bf75782020-05-19 02:31:31 +0200146<https://github.com/python/cpython/blob/3.9/Misc/NEWS.d>`_, but a full
Zachary Wared50f1882017-02-13 22:01:03 -0600147accounting of changes can only be gleaned from the `commit history
Łukasz Langa1bf75782020-05-19 02:31:31 +0200148<https://github.com/python/cpython/commits/3.9>`_.
Benjamin Peterson1da43e52009-06-26 13:21:52 +0000149
Hossein Pourbozorg5f2b3b02019-05-02 12:47:55 +0430150If you want to install multiple versions of Python, see the section below
Benjamin Peterson1da43e52009-06-26 13:21:52 +0000151entitled "Installing multiple versions".
Guido van Rossum8d90f9d1997-05-22 20:13:25 +0000152
Guido van Rossumf501b4e1996-10-25 14:32:48 +0000153
Guido van Rossumc07d5fa2000-09-01 22:50:02 +0000154Documentation
155-------------
Guido van Rossum91cb9d21995-04-10 11:47:38 +0000156
Łukasz Langa9ab2fb12019-06-04 22:12:32 +0200157`Documentation for Python 3.9 <https://docs.python.org/3.9/>`_ is online,
Victor Stinnerd783b012017-02-11 02:21:38 +0100158updated daily.
Guido van Rossumc07d5fa2000-09-01 22:50:02 +0000159
Georg Brandl62069d32010-07-31 08:56:11 +0000160It can also be downloaded in many formats for faster access. The documentation
161is downloadable in HTML, PDF, and reStructuredText formats; the latter version
162is primarily for documentation authors, translators, and people with special
163formatting requirements.
Benjamin Peterson2a691a82008-03-31 01:51:45 +0000164
Rogerb3f1f592017-02-15 17:54:05 -0500165For information about building Python's documentation, refer to `Doc/README.rst
Łukasz Langa1bf75782020-05-19 02:31:31 +0200166<https://github.com/python/cpython/blob/3.9/Doc/README.rst>`_.
Ezio Melotti802bf8a2013-08-16 21:32:25 +0300167
Guido van Rossumc07d5fa2000-09-01 22:50:02 +0000168
Barry Warsaw97f005d2008-12-03 16:46:14 +0000169Converting From Python 2.x to 3.x
Guido van Rossum1c896e32007-08-29 23:03:30 +0000170---------------------------------
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000171
Zachary Wared50f1882017-02-13 22:01:03 -0600172Significant backward incompatible changes were made for the release of Python
1733.0, which may cause programs written for Python 2 to fail when run with Python
1743. For more information about porting your code from Python 2 to Python 3, see
175the `Porting HOWTO <https://docs.python.org/3/howto/pyporting.html>`_.
Benjamin Peterson1da43e52009-06-26 13:21:52 +0000176
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000177
Benjamin Petersonad3d5c22009-02-26 03:38:59 +0000178Testing
179-------
180
Zachary Wared50f1882017-02-13 22:01:03 -0600181To test the interpreter, type ``make test`` in the top-level directory. The
182test set produces some output. You can generally ignore the messages about
183skipped tests due to optional features which can't be imported. If a message
184is printed about a failed test or a traceback or core dump is produced,
185something is wrong.
Benjamin Petersonad3d5c22009-02-26 03:38:59 +0000186
187By default, tests are prevented from overusing resources like disk space and
Victor Stinnerd783b012017-02-11 02:21:38 +0100188memory. To enable these tests, run ``make testall``.
Benjamin Petersonad3d5c22009-02-26 03:38:59 +0000189
Aaron Ang0f914b52018-04-09 14:09:31 -0700190If any tests fail, you can re-run the failing test(s) in verbose mode. For
191example, if ``test_os`` and ``test_gdb`` failed, you can run::
Benjamin Petersonad3d5c22009-02-26 03:38:59 +0000192
Aaron Ang0f914b52018-04-09 14:09:31 -0700193 make test TESTOPTS="-v test_os test_gdb"
Benjamin Petersonad3d5c22009-02-26 03:38:59 +0000194
Zachary Wared50f1882017-02-13 22:01:03 -0600195If the failure persists and appears to be a problem with Python rather than
196your environment, you can `file a bug report <https://bugs.python.org>`_ and
197include relevant output from that command to show the issue.
Benjamin Petersonad3d5c22009-02-26 03:38:59 +0000198
Michael Osipovcae8ff92018-08-17 23:43:34 +0200199See `Running & Writing Tests <https://devguide.python.org/runtests/>`_
200for more on running tests.
Benjamin Petersonad3d5c22009-02-26 03:38:59 +0000201
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000202Installing multiple versions
203----------------------------
204
205On Unix and Mac systems if you intend to install multiple versions of Python
Zachary Wared50f1882017-02-13 22:01:03 -0600206using the same installation prefix (``--prefix`` argument to the configure
207script) you must take care that your primary python executable is not
208overwritten by the installation of a different version. All files and
209directories installed using ``make altinstall`` contain the major and minor
210version and can thus live side-by-side. ``make install`` also creates
211``${prefix}/bin/python3`` which refers to ``${prefix}/bin/pythonX.Y``. If you
212intend to install multiple versions using the same prefix you must decide which
213version (if any) is your "primary" version. Install that version using ``make
214install``. Install all other versions using ``make altinstall``.
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000215
Łukasz Langa9ab2fb12019-06-04 22:12:32 +0200216For example, if you want to install Python 2.7, 3.6, and 3.9 with 3.9 being the
217primary version, you would execute ``make install`` in your 3.9 build directory
Victor Stinnerd783b012017-02-11 02:21:38 +0100218and ``make altinstall`` in the others.
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000219
220
Guido van Rossum1c896e32007-08-29 23:03:30 +0000221Issue Tracker and Mailing List
222------------------------------
Michael W. Hudson71dcc3e2005-02-22 15:33:26 +0000223
Zachary Wared50f1882017-02-13 22:01:03 -0600224Bug reports are welcome! You can use the `issue tracker
225<https://bugs.python.org>`_ to report bugs, and/or submit pull requests `on
226GitHub <https://github.com/python/cpython>`_.
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000227
Zachary Wared50f1882017-02-13 22:01:03 -0600228You can also follow development discussion on the `python-dev mailing list
229<https://mail.python.org/mailman/listinfo/python-dev/>`_.
Georg Brandl81299ad2006-02-20 10:24:06 +0000230
Michael W. Hudson71dcc3e2005-02-22 15:33:26 +0000231
Benjamin Peterson1da43e52009-06-26 13:21:52 +0000232Proposals for enhancement
233-------------------------
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000234
Benjamin Peterson1da43e52009-06-26 13:21:52 +0000235If you have a proposal to change Python, you may want to send an email to the
Zachary Wared50f1882017-02-13 22:01:03 -0600236comp.lang.python or `python-ideas`_ mailing lists for initial feedback. A
237Python Enhancement Proposal (PEP) may be submitted if your idea gains ground.
238All current PEPs, as well as guidelines for submitting a new PEP, are listed at
Victor Stinnerd783b012017-02-11 02:21:38 +0100239`python.org/dev/peps/ <https://www.python.org/dev/peps/>`_.
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000240
Ned Batchelder3cdbd682017-02-13 12:05:47 -0500241.. _python-ideas: https://mail.python.org/mailman/listinfo/python-ideas/
Guido van Rossum1c896e32007-08-29 23:03:30 +0000242
Zachary Wared50f1882017-02-13 22:01:03 -0600243
Benjamin Peterson1da43e52009-06-26 13:21:52 +0000244Release Schedule
245----------------
Guido van Rossum1c896e32007-08-29 23:03:30 +0000246
Łukasz Langa9ab2fb12019-06-04 22:12:32 +0200247See :pep:`596` for Python 3.9 release details.
Guido van Rossumef0f1292007-08-30 14:51:05 +0000248
249
250Copyright and License Information
251---------------------------------
252
Benjamin Peterson946b29e2020-01-02 18:56:34 -0800253Copyright (c) 2001-2020 Python Software Foundation. All rights reserved.
Guido van Rossumef0f1292007-08-30 14:51:05 +0000254
Georg Brandl260a7882011-02-20 10:29:04 +0000255Copyright (c) 2000 BeOpen.com. All rights reserved.
Guido van Rossumef0f1292007-08-30 14:51:05 +0000256
Georg Brandl260a7882011-02-20 10:29:04 +0000257Copyright (c) 1995-2001 Corporation for National Research Initiatives. All
258rights reserved.
Guido van Rossumef0f1292007-08-30 14:51:05 +0000259
Georg Brandl260a7882011-02-20 10:29:04 +0000260Copyright (c) 1991-1995 Stichting Mathematisch Centrum. All rights reserved.
Guido van Rossumef0f1292007-08-30 14:51:05 +0000261
Zachary Wared50f1882017-02-13 22:01:03 -0600262See the file "LICENSE" for information on the history of this software, terms &
263conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.
Guido van Rossumef0f1292007-08-30 14:51:05 +0000264
Larry Hastingsf92f6c82015-09-12 17:28:39 +0100265This Python distribution contains *no* GNU General Public License (GPL) code,
266so it may be used in proprietary projects. There are interfaces to some GNU
267code but these are entirely optional.
Guido van Rossumef0f1292007-08-30 14:51:05 +0000268
Georg Brandl260a7882011-02-20 10:29:04 +0000269All trademarks referenced herein are property of their respective holders.