Question about output different with command dis.dis(code)

Chris Angelico rosuav at gmail.com
Thu Nov 26 04:09:30 EST 2015


On Thu, Nov 26, 2015 at 8:02 PM, fl <rxjwg98 at gmail.com> wrote:
> Are there something, my input or Python difference
> make the output different?

Anything involving the disassembly of Python code depends heavily on
internal interpreter details. You just quoted something showing that
ancient versions of Python did at run-time what current versions have
optimized to a compile-time construction (and thus the quick
LOAD_CONST instead of the full work of building the tuple). If you
switch to PyPy, Jython, IronPython, or some other implementation of
the language, the byte code may be completely different - or may not
be available at all. Using dis.dis is a great way of finding out what
is actually happening, but it's never something you can depend on the
stability of.

ChrisA



More information about the Python-list mailing list