9c6e32f71d70659ad92b1cd6947602139840a41d
[python-guide.git] / docs / starting / which-python.rst
1 Picking an Interpreter
2 ======================
3
4 Which Python to use?
5
6
7 2.x vs 3.x
8 ~~~~~~~~~~
9
10 **tl;dr**: Python 2.x is the status quo, Python 3.x is the shiny new thing.
11
12
13 `Further Reading <http://wiki.python.org/moin/Python2orPython3>`_
14
15
16 Today
17 -----
18
19 If you're choosing a Python interpreter to use, I *highly* recommend you Use
20 Python 2.7.x, unless you have a strong reason not to.
21
22
23 The Future
24 ----------
25
26 As more and more modules get ported over to Python3, the easier it will be for
27 others to use it.
28
29
30 Which Python to Support?
31 ~~~~~~~~~~~~~~~~~~~~~~~~
32
33 If you're starting work on a new Python module, I recommend you write it for
34 Python 2.5 or 2.6, and add support for Python3 in a later iteration.
35
36 Implementations
37 ~~~~~~~~~~~~~~~
38
39 There are several popular implementations of the Python programming language on
40 different back-ends.
41
42 CPython
43 -------
44
45 `CPython <http://www.python.org>`_ is the reference implementation of Python,
46 written in C. It compiles Python code to intermediate bytecode which is then
47 interpreted by a virtual machine. When people speak of *Python* they often mean
48 not just the language but also this implementation. It provides the highest
49 level of compatibility with Python packages and C extension modules.
50
51 If you are writing open-source Python code and want to reach the widest possible
52 audience, targeting CPython is your best bet. If you need to use any packages
53 that are rely on C extensions for their functionality (eg: numpy) then CPython
54 is your only choice.
55
56 Being the reference implementation, all versions of the Python language are
57 available as CPython. Python 3 is only available in a CPython implementation.
58
59 PyPy
60 ----
61
62 `PyPy <http://pypy.org/>`_ is a Python interpreter implemented in a restricted
63 statically-typed subset of the Python language called RPython. The interpreter
64 features a just-in-time compiler and supports multiple back-ends (C, CLI, JVM).
65
66 PyPy aims for maximum compatibility with the reference CPython implementation
67 while improving performance.
68
69 If you are looking to squeeze more performance out of your Python code, it's
70 worth giving PyPy a try. On a suite of benchmarks, it's current `over 5 times
71 faster than CPython <http://speed.pypy.org/>`_.
72
73 Currently PyPy supports Python 2.7. [#pypy_ver]_
74
75 Jython
76 ------
77
78 `Jython <http://www.jython.org/>`_ is a Python implementation that compiles
79 Python code to Java byte code that then executes on a JVM. It has the additional
80 advantage of being able to import and use any Java class the same as a Python
81 module.
82
83 If you need to interface with an existing Java codebase or have other reasons to
84 need to write Python code for the JVM, Jython is the best choice.
85
86 Currently Jython supports up to Python 2.5. [#jython_ver]_
87
88 IronPython
89 ----------
90
91 `IronPython <http://ironpython.net/>`_  is an implementation of Python for .NET
92 framework. It can use both Python and .NET framework libraries, and can also
93 expose Python code to other .NET languages.
94
95 `Python Tools for Visual Studio <http://ironpython.net/tools/>`_ integrate
96 IronPython directly in to the Visual Studio development environment, making it
97 an ideal choice for Windows developers.
98
99 IronPython supports Python 2.7. [#iron_ver]_
100
101 .. [#pypy_ver] http://pypy.org/compat.html
102
103 .. [#jython_ver] http://wiki.python.org/jython/JythonFaq/GeneralInfo#Is_Jython_the_same_language_as_Python.3F
104
105 .. [#iron_ver] http://ironpython.codeplex.com/releases/view/54498