Skip to content

Commit

Permalink
Some people have mistaken Python bytecode as being stable and unchang…
Browse files Browse the repository at this point in the history
…ing. In

reality it's simply an implementation detail for CPython. This point is now
clearly documented in both the docs for dis and the glossary.

Closes issue #7829. Thanks to Terry Reedy for some initial suggestions on
wording.
  • Loading branch information
brettcannon committed Jul 2, 2010
1 parent be5846b commit 8315fd1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
13 changes: 8 additions & 5 deletions Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ Glossary

bytecode
Python source code is compiled into bytecode, the internal representation
of a Python program in the interpreter. The bytecode is also cached in
``.pyc`` and ``.pyo`` files so that executing the same file is faster the
second time (recompilation from source to bytecode can be avoided). This
"intermediate language" is said to run on a :term:`virtual machine`
that executes the machine code corresponding to each bytecode.
of a Python program in the CPython interpreter. The bytecode is also
cached in ``.pyc`` and ``.pyo`` files so that executing the same file is
faster the second time (recompilation from source to bytecode can be
avoided). This "intermediate language" is said to run on a
:term:`virtual machine` that executes the machine code corresponding to
each bytecode. Do note that bytecodes are not expected to work between
different Python virtual machines, nor to be stable between Python
releases.

class
A template for creating user-defined objects. Class definitions
Expand Down
7 changes: 4 additions & 3 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
:synopsis: Disassembler for Python bytecode.


The :mod:`dis` module supports the analysis of Python :term:`bytecode` by
disassembling it. Since there is no Python assembler, this module defines the
Python assembly language. The Python bytecode which this module takes as an
The :mod:`dis` module supports the analysis of CPython :term:`bytecode` by
disassembling it. The CPython bytecode which this module takes as an
input is defined in the file :file:`Include/opcode.h` and used by the compiler
and the interpreter.

.. warning:: Bytecode is an implementation detail of the CPython interpreter! No guarantees are made that bytecode will not be added, removed, or changed between versions of Python. Use of this module should not be considered to work across Python VMs or Python releases.

Example: Given the function :func:`myfunc`::

def myfunc(alist):
Expand Down
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ C-API
Library
-------

- Issue #7829: Clearly document that the dis module is exposing an
implementation detail that is not stable between Python VMs or releases.

- Issue #6589: cleanup asyncore.socket_map in case smtpd.SMTPServer constructor
raises an exception.

Expand Down

0 comments on commit 8315fd1

Please sign in to comment.