diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2017-02-09 16:08:17 +0100 |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2017-02-09 16:08:17 +0100 |
commit | c6180bb73c8c7c7f9d8ea9816487b710597b6fc1 (patch) | |
tree | fb4a5c18886537b4b7df46ed3b2aa579747ff507 /Doc/faq | |
parent | 5e0114a832a903518c4af6983161c0c2a8942a24 (diff) | |
parent | 819a21a3a4aac38f32e1ba4f68bcef45591fa3f0 (diff) | |
download | cpython-c6180bb73c8c7c7f9d8ea9816487b710597b6fc1.tar.gz |
Merge issue #26355 fix from Python 3.5
Diffstat (limited to 'Doc/faq')
-rw-r--r-- | Doc/faq/design.rst | 32 | ||||
-rw-r--r-- | Doc/faq/programming.rst | 3 |
2 files changed, 7 insertions, 28 deletions
diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst index 108df6d17a..1bd800b1a8 100644 --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -366,33 +366,11 @@ is exactly the same type of object that a lambda expression yields) is assigned! Can Python be compiled to machine code, C or some other language? ----------------------------------------------------------------- -Practical answer: - -`Cython <http://cython.org/>`_ and `Pyrex <https://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/>`_ -compile a modified version of Python with optional annotations into C -extensions. `Weave <https://scipy.github.io/devdocs/tutorial/weave.html>`_ makes it easy to -intermingle Python and C code in various ways to increase performance. -`Nuitka <http://www.nuitka.net/>`_ is an up-and-coming compiler of Python -into C++ code, aiming to support the full Python language. - -Theoretical answer: - - .. XXX not sure what to make of this - -Not trivially. Python's high level data types, dynamic typing of objects and -run-time invocation of the interpreter (using :func:`eval` or :func:`exec`) -together mean that a naïvely "compiled" Python program would probably consist -mostly of calls into the Python run-time system, even for seemingly simple -operations like ``x+1``. - -Several projects described in the Python newsgroup or at past `Python -conferences <https://www.python.org/community/workshops/>`_ have shown that this -approach is feasible, although the speedups reached so far are only modest -(e.g. 2x). Jython uses the same strategy for compiling to Java bytecode. (Jim -Hugunin has demonstrated that in combination with whole-program analysis, -speedups of 1000x are feasible for small demo programs. See the proceedings -from the `1997 Python conference -<http://legacy.python.org/workshops/1997-10/proceedings/>`_ for more information.) +`Cython <http://cython.org/>`_ compiles a modified version of Python with +optional annotations into C extensions. `Nuitka <http://www.nuitka.net/>`_ is +an up-and-coming compiler of Python into C++ code, aiming to support the full +Python language. For compiling to Java you can consider +`VOC <https://voc.readthedocs.io>`_. How does Python manage memory? diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index 694753e5b9..9c5e20dcad 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -838,7 +838,8 @@ How do I convert a number to a string? To convert, e.g., the number 144 to the string '144', use the built-in type constructor :func:`str`. If you want a hexadecimal or octal representation, use the built-in functions :func:`hex` or :func:`oct`. For fancy formatting, see -the :ref:`formatstrings` section, e.g. ``"{:04d}".format(144)`` yields +the :ref:`f-strings` and :ref:`formatstrings` sections, +e.g. ``"{:04d}".format(144)`` yields ``'0144'`` and ``"{:.3f}".format(1.0/3.0)`` yields ``'0.333'``. |