GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python-doc-tw.github.io/library/dis.html at master · python-doc-tw/python-doc-tw.github.io Expand file tree/ Copy pathdis.htmlMore file actions 1587 lines (1412 loc) · 105 KB / Copy pathdis.htmlFile metadata and controls1587 lines (1412 loc) · 105 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="zh_TW"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>33.12. dis — Python bytecode的反組譯器 — Python 3.7.0 說明文件</title> <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/translations.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="在 Python 3.7.0 說明文件 中搜尋" href="../_static/opensearch.xml"/> <link rel="author" title="關於這些文件" href="../about.html" /> <link rel="index" title="索引" href="../genindex.html" /> <link rel="search" title="搜尋" href="../search.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="next" title="33.13. pickletools — Tools for pickle developers" href="pickletools.html" /> <link rel="prev" title="33.11. compileall — Byte-compile Python libraries" href="compileall.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <link rel="canonical" href="https://docs.python.org/3/library/dis.html" /> <script type="text/javascript" src="../_static/copybutton.js"></script> <script type="text/javascript" src="../_static/switchers.js"></script> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>瀏覽</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">索引</a></li> <li class="right" > <a href="../py-modindex.html" title="Python 模組索引" >模組</a> |</li> <li class="right" > <a href="pickletools.html" title="33.13. pickletools — Tools for pickle developers" accesskey="N">下一頁</a> |</li> <li class="right" > <a href="compileall.html" title="33.11. compileall — Byte-compile Python libraries" accesskey="P">上一頁</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <span class="language_switcher_placeholder">zh_TW</span> <span class="version_switcher_placeholder">3.7.0</span> <a href="../index.html">Documentation </a> » </li> <li class="nav-item nav-item-1"><a href="index.html" >Python 標準函式庫 (Standard Library)</a> »</li> <li class="nav-item nav-item-2"><a href="language.html" accesskey="U">33. Python Language Services</a> »</li> <li class="right"> <div class="inline-search" style="display: none" role="search"> <form class="inline-search" action="../search.html" method="get"> <input placeholder="Quick search" type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> <script type="text/javascript">$('.inline-search').show(0);</script> | </li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="module-dis"> <span id="dis-disassembler-for-python-bytecode"></span><h1>33.12. <a class="reference internal" href="#module-dis" title="dis: Disassembler for Python bytecode."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a> — Python bytecode的反組譯器<a class="headerlink" href="#module-dis" title="本標題的永久連結">¶</a></h1> <p><strong>原始碼:</strong><a class="reference external" href="https://github.com/python/cpython/tree/3.7/Lib/dis.py">Lib/dis.py</a></p> <hr class="docutils" /> <p><a class="reference internal" href="#module-dis" title="dis: Disassembler for Python bytecode."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a> 模組支援反組譯分析 CPython <a class="reference internal" href="../glossary.html#term-bytecode"><span class="xref std std-term">bytecode</span></a>。CPython bytecode 作為輸入的模組被定義於 <code class="file docutils literal notranslate"><span class="pre">Include/opcode.h</span></code> 並且被編譯器和直譯器所使用。</p> <div class="impl-detail compound"> <p class="compound-first"><strong>CPython implementation detail:</strong> 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.</p> <div class="compound-last versionchanged"> <p><span class="versionmodified">3.6 版更變: </span>Use 2 bytes for each instruction. Previously the number of bytes varied by instruction.</p> </div> </div> <p>Example: Given the function <code class="xref py py-func docutils literal notranslate"><span class="pre">myfunc()</span></code>:</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">myfunc</span><span class="p">(</span><span class="n">alist</span><span class="p">):</span> <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="n">alist</span><span class="p">)</span> </pre></div> </div> <p>the following command can be used to display the disassembly of <code class="xref py py-func docutils literal notranslate"><span class="pre">myfunc()</span></code>:</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dis</span><span class="o">.</span><span class="n">dis</span><span class="p">(</span><span class="n">myfunc</span><span class="p">)</span> <span class="go"> 2 0 LOAD_GLOBAL 0 (len)</span> <span class="go"> 2 LOAD_FAST 0 (alist)</span> <span class="go"> 4 CALL_FUNCTION 1</span> <span class="go"> 6 RETURN_VALUE</span> </pre></div> </div> <p>(The 「2」 is a line number).</p> <div class="section" id="bytecode-analysis"> <h2>33.12.1. Bytecode analysis<a class="headerlink" href="#bytecode-analysis" title="本標題的永久連結">¶</a></h2> <div class="versionadded"> <p><span class="versionmodified">3.4 版新加入.</span></p> </div> <p>The bytecode analysis API allows pieces of Python code to be wrapped in a <a class="reference internal" href="#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> object that provides easy access to details of the compiled code.</p> <dl class="class"> <dt id="dis.Bytecode"> <em class="property">class </em><code class="descclassname">dis.</code><code class="descname">Bytecode</code><span class="sig-paren">(</span><em>x</em>, <em>*</em>, <em>first_line=None</em>, <em>current_offset=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.Bytecode" title="本定義的永久連結">¶</a></dt> <dd><p>Analyse the bytecode corresponding to a function, generator, asynchronous generator, coroutine, method, string of source code, or a code object (as returned by <a class="reference internal" href="functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a>).</p> <p>This is a convenience wrapper around many of the functions listed below, most notably <a class="reference internal" href="#dis.get_instructions" title="dis.get_instructions"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_instructions()</span></code></a>, as iterating over a <a class="reference internal" href="#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> instance yields the bytecode operations as <a class="reference internal" href="#dis.Instruction" title="dis.Instruction"><code class="xref py py-class docutils literal notranslate"><span class="pre">Instruction</span></code></a> instances.</p> <p>If <em>first_line</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, it indicates the line number that should be reported for the first source line in the disassembled code. Otherwise, the source line information (if any) is taken directly from the disassembled code object.</p> <p>If <em>current_offset</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, it refers to an instruction offset in the disassembled code. Setting this means <a class="reference internal" href="#dis.Bytecode.dis" title="dis.Bytecode.dis"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dis()</span></code></a> will display a 「current instruction」 marker against the specified opcode.</p> <dl class="classmethod"> <dt id="dis.Bytecode.from_traceback"> <em class="property">classmethod </em><code class="descname">from_traceback</code><span class="sig-paren">(</span><em>tb</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.Bytecode.from_traceback" title="本定義的永久連結">¶</a></dt> <dd><p>Construct a <a class="reference internal" href="#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> instance from the given traceback, setting <em>current_offset</em> to the instruction responsible for the exception.</p> </dd></dl> <dl class="data"> <dt id="dis.Bytecode.codeobj"> <code class="descname">codeobj</code><a class="headerlink" href="#dis.Bytecode.codeobj" title="本定義的永久連結">¶</a></dt> <dd><p>The compiled code object.</p> </dd></dl> <dl class="data"> <dt id="dis.Bytecode.first_line"> <code class="descname">first_line</code><a class="headerlink" href="#dis.Bytecode.first_line" title="本定義的永久連結">¶</a></dt> <dd><p>The first source line of the code object (if available)</p> </dd></dl> <dl class="method"> <dt id="dis.Bytecode.dis"> <code class="descname">dis</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#dis.Bytecode.dis" title="本定義的永久連結">¶</a></dt> <dd><p>Return a formatted view of the bytecode operations (the same as printed by <a class="reference internal" href="#dis.dis" title="dis.dis"><code class="xref py py-func docutils literal notranslate"><span class="pre">dis.dis()</span></code></a>, but returned as a multi-line string).</p> </dd></dl> <dl class="method"> <dt id="dis.Bytecode.info"> <code class="descname">info</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#dis.Bytecode.info" title="本定義的永久連結">¶</a></dt> <dd><p>Return a formatted multi-line string with detailed information about the code object, like <a class="reference internal" href="#dis.code_info" title="dis.code_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">code_info()</span></code></a>.</p> </dd></dl> <div class="versionchanged"> <p><span class="versionmodified">3.7 版更變: </span>This can now handle coroutine and asynchronous generator objects.</p> </div> </dd></dl> <p>Example:</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">bytecode</span> <span class="o">=</span> <span class="n">dis</span><span class="o">.</span><span class="n">Bytecode</span><span class="p">(</span><span class="n">myfunc</span><span class="p">)</span> <span class="gp">>>> </span><span class="k">for</span> <span class="n">instr</span> <span class="ow">in</span> <span class="n">bytecode</span><span class="p">:</span> <span class="gp">... </span> <span class="nb">print</span><span class="p">(</span><span class="n">instr</span><span class="o">.</span><span class="n">opname</span><span class="p">)</span> <span class="gp">...</span> <span class="go">LOAD_GLOBAL</span> <span class="go">LOAD_FAST</span> <span class="go">CALL_FUNCTION</span> <span class="go">RETURN_VALUE</span> </pre></div> </div> </div> <div class="section" id="analysis-functions"> <h2>33.12.2. Analysis functions<a class="headerlink" href="#analysis-functions" title="本標題的永久連結">¶</a></h2> <p>The <a class="reference internal" href="#module-dis" title="dis: Disassembler for Python bytecode."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code></a> module also defines the following analysis functions that convert the input directly to the desired output. They can be useful if only a single operation is being performed, so the intermediate analysis object isn’t useful:</p> <dl class="function"> <dt id="dis.code_info"> <code class="descclassname">dis.</code><code class="descname">code_info</code><span class="sig-paren">(</span><em>x</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.code_info" title="本定義的永久連結">¶</a></dt> <dd><p>Return a formatted multi-line string with detailed code object information for the supplied function, generator, asynchronous generator, coroutine, method, source code string or code object.</p> <p>Note that the exact contents of code info strings are highly implementation dependent and they may change arbitrarily across Python VMs or Python releases.</p> <div class="versionadded"> <p><span class="versionmodified">3.2 版新加入.</span></p> </div> <div class="versionchanged"> <p><span class="versionmodified">3.7 版更變: </span>This can now handle coroutine and asynchronous generator objects.</p> </div> </dd></dl> <dl class="function"> <dt id="dis.show_code"> <code class="descclassname">dis.</code><code class="descname">show_code</code><span class="sig-paren">(</span><em>x</em>, <em>*</em>, <em>file=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.show_code" title="本定義的永久連結">¶</a></dt> <dd><p>Print detailed code object information for the supplied function, method, source code string or code object to <em>file</em> (or <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> if <em>file</em> is not specified).</p> <p>This is a convenient shorthand for <code class="docutils literal notranslate"><span class="pre">print(code_info(x),</span> <span class="pre">file=file)</span></code>, intended for interactive exploration at the interpreter prompt.</p> <div class="versionadded"> <p><span class="versionmodified">3.2 版新加入.</span></p> </div> <div class="versionchanged"> <p><span class="versionmodified">3.4 版更變: </span>Added <em>file</em> parameter.</p> </div> </dd></dl> <dl class="function"> <dt id="dis.dis"> <code class="descclassname">dis.</code><code class="descname">dis</code><span class="sig-paren">(</span><em>x=None</em>, <em>*</em>, <em>file=None</em>, <em>depth=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.dis" title="本定義的永久連結">¶</a></dt> <dd><p>Disassemble the <em>x</em> object. <em>x</em> can denote either a module, a class, a method, a function, a generator, an asynchronous generator, a couroutine, a code object, a string of source code or a byte sequence of raw bytecode. For a module, it disassembles all functions. For a class, it disassembles all methods (including class and static methods). For a code object or sequence of raw bytecode, it prints one line per bytecode instruction. It also recursively disassembles nested code objects (the code of comprehensions, generator expressions and nested functions, and the code used for building nested classes). Strings are first compiled to code objects with the <a class="reference internal" href="functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a> built-in function before being disassembled. If no object is provided, this function disassembles the last traceback.</p> <p>The disassembly is written as text to the supplied <em>file</em> argument if provided and to <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> otherwise.</p> <p>The maximal depth of recursion is limited by <em>depth</em> unless it is <code class="docutils literal notranslate"><span class="pre">None</span></code>. <code class="docutils literal notranslate"><span class="pre">depth=0</span></code> means no recursion.</p> <div class="versionchanged"> <p><span class="versionmodified">3.4 版更變: </span>Added <em>file</em> parameter.</p> </div> <div class="versionchanged"> <p><span class="versionmodified">3.7 版更變: </span>Implemented recursive disassembling and added <em>depth</em> parameter.</p> </div> <div class="versionchanged"> <p><span class="versionmodified">3.7 版更變: </span>This can now handle coroutine and asynchronous generator objects.</p> </div> </dd></dl> <dl class="function"> <dt id="dis.distb"> <code class="descclassname">dis.</code><code class="descname">distb</code><span class="sig-paren">(</span><em>tb=None</em>, <em>*</em>, <em>file=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.distb" title="本定義的永久連結">¶</a></dt> <dd><p>Disassemble the top-of-stack function of a traceback, using the last traceback if none was passed. The instruction causing the exception is indicated.</p> <p>The disassembly is written as text to the supplied <em>file</em> argument if provided and to <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> otherwise.</p> <div class="versionchanged"> <p><span class="versionmodified">3.4 版更變: </span>Added <em>file</em> parameter.</p> </div> </dd></dl> <dl class="function"> <dt id="dis.disassemble"> <code class="descclassname">dis.</code><code class="descname">disassemble</code><span class="sig-paren">(</span><em>code</em>, <em>lasti=-1</em>, <em>*</em>, <em>file=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.disassemble" title="本定義的永久連結">¶</a></dt> <dt id="dis.disco"> <code class="descclassname">dis.</code><code class="descname">disco</code><span class="sig-paren">(</span><em>code</em>, <em>lasti=-1</em>, <em>*</em>, <em>file=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.disco" title="本定義的永久連結">¶</a></dt> <dd><p>Disassemble a code object, indicating the last instruction if <em>lasti</em> was provided. The output is divided in the following columns:</p> <ol class="arabic simple"> <li>the line number, for the first instruction of each line</li> <li>the current instruction, indicated as <code class="docutils literal notranslate"><span class="pre">--></span></code>,</li> <li>a labelled instruction, indicated with <code class="docutils literal notranslate"><span class="pre">>></span></code>,</li> <li>the address of the instruction,</li> <li>the operation code name,</li> <li>operation parameters, and</li> <li>interpretation of the parameters in parentheses.</li> </ol> <p>The parameter interpretation recognizes local and global variable names, constant values, branch targets, and compare operators.</p> <p>The disassembly is written as text to the supplied <em>file</em> argument if provided and to <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> otherwise.</p> <div class="versionchanged"> <p><span class="versionmodified">3.4 版更變: </span>Added <em>file</em> parameter.</p> </div> </dd></dl> <dl class="function"> <dt id="dis.get_instructions"> <code class="descclassname">dis.</code><code class="descname">get_instructions</code><span class="sig-paren">(</span><em>x</em>, <em>*</em>, <em>first_line=None</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.get_instructions" title="本定義的永久連結">¶</a></dt> <dd><p>Return an iterator over the instructions in the supplied function, method, source code string or code object.</p> <p>The iterator generates a series of <a class="reference internal" href="#dis.Instruction" title="dis.Instruction"><code class="xref py py-class docutils literal notranslate"><span class="pre">Instruction</span></code></a> named tuples giving the details of each operation in the supplied code.</p> <p>If <em>first_line</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, it indicates the line number that should be reported for the first source line in the disassembled code. Otherwise, the source line information (if any) is taken directly from the disassembled code object.</p> <div class="versionadded"> <p><span class="versionmodified">3.4 版新加入.</span></p> </div> </dd></dl> <dl class="function"> <dt id="dis.findlinestarts"> <code class="descclassname">dis.</code><code class="descname">findlinestarts</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.findlinestarts" title="本定義的永久連結">¶</a></dt> <dd><p>This generator function uses the <code class="docutils literal notranslate"><span class="pre">co_firstlineno</span></code> and <code class="docutils literal notranslate"><span class="pre">co_lnotab</span></code> attributes of the code object <em>code</em> to find the offsets which are starts of lines in the source code. They are generated as <code class="docutils literal notranslate"><span class="pre">(offset,</span> <span class="pre">lineno)</span></code> pairs. See <a class="reference external" href="https://github.com/python/cpython/tree/3.7/Objects/lnotab_notes.txt">Objects/lnotab_notes.txt</a> for the <code class="docutils literal notranslate"><span class="pre">co_lnotab</span></code> format and how to decode it.</p> <div class="versionchanged"> <p><span class="versionmodified">3.6 版更變: </span>Line numbers can be decreasing. Before, they were always increasing.</p> </div> </dd></dl> <dl class="function"> <dt id="dis.findlabels"> <code class="descclassname">dis.</code><code class="descname">findlabels</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="headerlink" href="#dis.findlabels" title="本定義的永久連結">¶</a></dt> <dd><p>Detect all offsets in the code object <em>code</em> which are jump targets, and return a list of these offsets.</p> </dd></dl> <dl class="function"> <dt id="dis.stack_effect"> <code class="descclassname">dis.</code><code class="descname">stack_effect</code><span class="sig-paren">(</span><em>opcode</em><span class="optional">[</span>, <em>oparg</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#dis.stack_effect" title="本定義的永久連結">¶</a></dt> <dd><p>Compute the stack effect of <em>opcode</em> with argument <em>oparg</em>.</p> <div class="versionadded"> <p><span class="versionmodified">3.4 版新加入.</span></p> </div> </dd></dl> </div> <div class="section" id="python-bytecode-instructions"> <span id="bytecodes"></span><h2>33.12.3. Python Bytecode Instructions<a class="headerlink" href="#python-bytecode-instructions" title="本標題的永久連結">¶</a></h2> <p>The <a class="reference internal" href="#dis.get_instructions" title="dis.get_instructions"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_instructions()</span></code></a> function and <a class="reference internal" href="#dis.Bytecode" title="dis.Bytecode"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bytecode</span></code></a> class provide details of bytecode instructions as <a class="reference internal" href="#dis.Instruction" title="dis.Instruction"><code class="xref py py-class docutils literal notranslate"><span class="pre">Instruction</span></code></a> instances:</p> <dl class="class"> <dt id="dis.Instruction"> <em class="property">class </em><code class="descclassname">dis.</code><code class="descname">Instruction</code><a class="headerlink" href="#dis.Instruction" title="本定義的永久連結">¶</a></dt> <dd><p>Details for a bytecode operation</p> <dl class="data"> <dt id="dis.Instruction.opcode"> <code class="descname">opcode</code><a class="headerlink" href="#dis.Instruction.opcode" title="本定義的永久連結">¶</a></dt> <dd><p>numeric code for operation, corresponding to the opcode values listed below and the bytecode values in the <a class="reference internal" href="#opcode-collections"><span class="std std-ref">Opcode collections</span></a>.</p> </dd></dl> <dl class="data"> <dt id="dis.Instruction.opname"> <code class="descname">opname</code><a class="headerlink" href="#dis.Instruction.opname" title="本定義的永久連結">¶</a></dt> <dd><p>human readable name for operation</p> </dd></dl> <dl class="data"> <dt id="dis.Instruction.arg"> <code class="descname">arg</code><a class="headerlink" href="#dis.Instruction.arg" title="本定義的永久連結">¶</a></dt> <dd><p>numeric argument to operation (if any), otherwise <code class="docutils literal notranslate"><span class="pre">None</span></code></p> </dd></dl> <dl class="data"> <dt id="dis.Instruction.argval"> <code class="descname">argval</code><a class="headerlink" href="#dis.Instruction.argval" title="本定義的永久連結">¶</a></dt> <dd><p>resolved arg value (if known), otherwise same as arg</p> </dd></dl> <dl class="data"> <dt id="dis.Instruction.argrepr"> <code class="descname">argrepr</code><a class="headerlink" href="#dis.Instruction.argrepr" title="本定義的永久連結">¶</a></dt> <dd><p>human readable description of operation argument</p> </dd></dl> <dl class="data"> <dt id="dis.Instruction.offset"> <code class="descname">offset</code><a class="headerlink" href="#dis.Instruction.offset" title="本定義的永久連結">¶</a></dt> <dd><p>start index of operation within bytecode sequence</p> </dd></dl> <dl class="data"> <dt id="dis.Instruction.starts_line"> <code class="descname">starts_line</code><a class="headerlink" href="#dis.Instruction.starts_line" title="本定義的永久連結">¶</a></dt> <dd><p>line started by this opcode (if any), otherwise <code class="docutils literal notranslate"><span class="pre">None</span></code></p> </dd></dl> <dl class="data"> <dt id="dis.Instruction.is_jump_target"> <code class="descname">is_jump_target</code><a class="headerlink" href="#dis.Instruction.is_jump_target" title="本定義的永久連結">¶</a></dt> <dd><p><code class="docutils literal notranslate"><span class="pre">True</span></code> if other code jumps to here, otherwise <code class="docutils literal notranslate"><span class="pre">False</span></code></p> </dd></dl> <div class="versionadded"> <p><span class="versionmodified">3.4 版新加入.</span></p> </div> </dd></dl> <p>The Python compiler currently generates the following bytecode instructions.</p> <p><strong>General instructions</strong></p> <dl class="opcode"> <dt id="opcode-NOP"> <code class="descname">NOP</code><a class="headerlink" href="#opcode-NOP" title="本定義的永久連結">¶</a></dt> <dd><p>Do nothing code. Used as a placeholder by the bytecode optimizer.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-POP_TOP"> <code class="descname">POP_TOP</code><a class="headerlink" href="#opcode-POP_TOP" title="本定義的永久連結">¶</a></dt> <dd><p>Removes the top-of-stack (TOS) item.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-ROT_TWO"> <code class="descname">ROT_TWO</code><a class="headerlink" href="#opcode-ROT_TWO" title="本定義的永久連結">¶</a></dt> <dd><p>Swaps the two top-most stack items.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-ROT_THREE"> <code class="descname">ROT_THREE</code><a class="headerlink" href="#opcode-ROT_THREE" title="本定義的永久連結">¶</a></dt> <dd><p>Lifts second and third stack item one position up, moves top down to position three.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-DUP_TOP"> <code class="descname">DUP_TOP</code><a class="headerlink" href="#opcode-DUP_TOP" title="本定義的永久連結">¶</a></dt> <dd><p>Duplicates the reference on top of the stack.</p> <div class="versionadded"> <p><span class="versionmodified">3.2 版新加入.</span></p> </div> </dd></dl> <dl class="opcode"> <dt id="opcode-DUP_TOP_TWO"> <code class="descname">DUP_TOP_TWO</code><a class="headerlink" href="#opcode-DUP_TOP_TWO" title="本定義的永久連結">¶</a></dt> <dd><p>Duplicates the two references on top of the stack, leaving them in the same order.</p> <div class="versionadded"> <p><span class="versionmodified">3.2 版新加入.</span></p> </div> </dd></dl> <p><strong>Unary operations</strong></p> <p>Unary operations take the top of the stack, apply the operation, and push the result back on the stack.</p> <dl class="opcode"> <dt id="opcode-UNARY_POSITIVE"> <code class="descname">UNARY_POSITIVE</code><a class="headerlink" href="#opcode-UNARY_POSITIVE" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">+TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-UNARY_NEGATIVE"> <code class="descname">UNARY_NEGATIVE</code><a class="headerlink" href="#opcode-UNARY_NEGATIVE" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">-TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-UNARY_NOT"> <code class="descname">UNARY_NOT</code><a class="headerlink" href="#opcode-UNARY_NOT" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">not</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-UNARY_INVERT"> <code class="descname">UNARY_INVERT</code><a class="headerlink" href="#opcode-UNARY_INVERT" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">~TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-GET_ITER"> <code class="descname">GET_ITER</code><a class="headerlink" href="#opcode-GET_ITER" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">iter(TOS)</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-GET_YIELD_FROM_ITER"> <code class="descname">GET_YIELD_FROM_ITER</code><a class="headerlink" href="#opcode-GET_YIELD_FROM_ITER" title="本定義的永久連結">¶</a></dt> <dd><p>If <code class="docutils literal notranslate"><span class="pre">TOS</span></code> is a <a class="reference internal" href="../glossary.html#term-generator-iterator"><span class="xref std std-term">generator iterator</span></a> or <a class="reference internal" href="../glossary.html#term-coroutine"><span class="xref std std-term">coroutine</span></a> object it is left as is. Otherwise, implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">iter(TOS)</span></code>.</p> <div class="versionadded"> <p><span class="versionmodified">3.5 版新加入.</span></p> </div> </dd></dl> <p><strong>Binary operations</strong></p> <p>Binary operations remove the top of the stack (TOS) and the second top-most stack item (TOS1) from the stack. They perform the operation, and put the result back on the stack.</p> <dl class="opcode"> <dt id="opcode-BINARY_POWER"> <code class="descname">BINARY_POWER</code><a class="headerlink" href="#opcode-BINARY_POWER" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">**</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_MULTIPLY"> <code class="descname">BINARY_MULTIPLY</code><a class="headerlink" href="#opcode-BINARY_MULTIPLY" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">*</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_MATRIX_MULTIPLY"> <code class="descname">BINARY_MATRIX_MULTIPLY</code><a class="headerlink" href="#opcode-BINARY_MATRIX_MULTIPLY" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">@</span> <span class="pre">TOS</span></code>.</p> <div class="versionadded"> <p><span class="versionmodified">3.5 版新加入.</span></p> </div> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_FLOOR_DIVIDE"> <code class="descname">BINARY_FLOOR_DIVIDE</code><a class="headerlink" href="#opcode-BINARY_FLOOR_DIVIDE" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">//</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_TRUE_DIVIDE"> <code class="descname">BINARY_TRUE_DIVIDE</code><a class="headerlink" href="#opcode-BINARY_TRUE_DIVIDE" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">/</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_MODULO"> <code class="descname">BINARY_MODULO</code><a class="headerlink" href="#opcode-BINARY_MODULO" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">%</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_ADD"> <code class="descname">BINARY_ADD</code><a class="headerlink" href="#opcode-BINARY_ADD" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">+</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_SUBTRACT"> <code class="descname">BINARY_SUBTRACT</code><a class="headerlink" href="#opcode-BINARY_SUBTRACT" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">-</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_SUBSCR"> <code class="descname">BINARY_SUBSCR</code><a class="headerlink" href="#opcode-BINARY_SUBSCR" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1[TOS]</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_LSHIFT"> <code class="descname">BINARY_LSHIFT</code><a class="headerlink" href="#opcode-BINARY_LSHIFT" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre"><<</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_RSHIFT"> <code class="descname">BINARY_RSHIFT</code><a class="headerlink" href="#opcode-BINARY_RSHIFT" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">>></span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_AND"> <code class="descname">BINARY_AND</code><a class="headerlink" href="#opcode-BINARY_AND" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">&</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_XOR"> <code class="descname">BINARY_XOR</code><a class="headerlink" href="#opcode-BINARY_XOR" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">^</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BINARY_OR"> <code class="descname">BINARY_OR</code><a class="headerlink" href="#opcode-BINARY_OR" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">|</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <p><strong>In-place operations</strong></p> <p>In-place operations are like binary operations, in that they remove TOS and TOS1, and push the result back on the stack, but the operation is done in-place when TOS1 supports it, and the resulting TOS may be (but does not have to be) the original TOS1.</p> <dl class="opcode"> <dt id="opcode-INPLACE_POWER"> <code class="descname">INPLACE_POWER</code><a class="headerlink" href="#opcode-INPLACE_POWER" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">**</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_MULTIPLY"> <code class="descname">INPLACE_MULTIPLY</code><a class="headerlink" href="#opcode-INPLACE_MULTIPLY" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">*</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_MATRIX_MULTIPLY"> <code class="descname">INPLACE_MATRIX_MULTIPLY</code><a class="headerlink" href="#opcode-INPLACE_MATRIX_MULTIPLY" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">@</span> <span class="pre">TOS</span></code>.</p> <div class="versionadded"> <p><span class="versionmodified">3.5 版新加入.</span></p> </div> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_FLOOR_DIVIDE"> <code class="descname">INPLACE_FLOOR_DIVIDE</code><a class="headerlink" href="#opcode-INPLACE_FLOOR_DIVIDE" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">//</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_TRUE_DIVIDE"> <code class="descname">INPLACE_TRUE_DIVIDE</code><a class="headerlink" href="#opcode-INPLACE_TRUE_DIVIDE" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">/</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_MODULO"> <code class="descname">INPLACE_MODULO</code><a class="headerlink" href="#opcode-INPLACE_MODULO" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">%</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_ADD"> <code class="descname">INPLACE_ADD</code><a class="headerlink" href="#opcode-INPLACE_ADD" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">+</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_SUBTRACT"> <code class="descname">INPLACE_SUBTRACT</code><a class="headerlink" href="#opcode-INPLACE_SUBTRACT" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">-</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_LSHIFT"> <code class="descname">INPLACE_LSHIFT</code><a class="headerlink" href="#opcode-INPLACE_LSHIFT" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre"><<</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_RSHIFT"> <code class="descname">INPLACE_RSHIFT</code><a class="headerlink" href="#opcode-INPLACE_RSHIFT" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">>></span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_AND"> <code class="descname">INPLACE_AND</code><a class="headerlink" href="#opcode-INPLACE_AND" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">&</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_XOR"> <code class="descname">INPLACE_XOR</code><a class="headerlink" href="#opcode-INPLACE_XOR" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">^</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-INPLACE_OR"> <code class="descname">INPLACE_OR</code><a class="headerlink" href="#opcode-INPLACE_OR" title="本定義的永久連結">¶</a></dt> <dd><p>Implements in-place <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS1</span> <span class="pre">|</span> <span class="pre">TOS</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-STORE_SUBSCR"> <code class="descname">STORE_SUBSCR</code><a class="headerlink" href="#opcode-STORE_SUBSCR" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS1[TOS]</span> <span class="pre">=</span> <span class="pre">TOS2</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-DELETE_SUBSCR"> <code class="descname">DELETE_SUBSCR</code><a class="headerlink" href="#opcode-DELETE_SUBSCR" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">del</span> <span class="pre">TOS1[TOS]</span></code>.</p> </dd></dl> <p><strong>Coroutine opcodes</strong></p> <dl class="opcode"> <dt id="opcode-GET_AWAITABLE"> <code class="descname">GET_AWAITABLE</code><a class="headerlink" href="#opcode-GET_AWAITABLE" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">get_awaitable(TOS)</span></code>, where <code class="docutils literal notranslate"><span class="pre">get_awaitable(o)</span></code> returns <code class="docutils literal notranslate"><span class="pre">o</span></code> if <code class="docutils literal notranslate"><span class="pre">o</span></code> is a coroutine object or a generator object with the CO_ITERABLE_COROUTINE flag, or resolves <code class="docutils literal notranslate"><span class="pre">o.__await__</span></code>.</p> <div class="versionadded"> <p><span class="versionmodified">3.5 版新加入.</span></p> </div> </dd></dl> <dl class="opcode"> <dt id="opcode-GET_AITER"> <code class="descname">GET_AITER</code><a class="headerlink" href="#opcode-GET_AITER" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS</span> <span class="pre">=</span> <span class="pre">TOS.__aiter__()</span></code>.</p> <div class="versionadded"> <p><span class="versionmodified">3.5 版新加入.</span></p> </div> <div class="versionchanged"> <p><span class="versionmodified">3.7 版更變: </span>Returning awaitable objects from <code class="docutils literal notranslate"><span class="pre">__aiter__</span></code> is no longer supported.</p> </div> </dd></dl> <dl class="opcode"> <dt id="opcode-GET_ANEXT"> <code class="descname">GET_ANEXT</code><a class="headerlink" href="#opcode-GET_ANEXT" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">PUSH(get_awaitable(TOS.__anext__()))</span></code>. See <code class="docutils literal notranslate"><span class="pre">GET_AWAITABLE</span></code> for details about <code class="docutils literal notranslate"><span class="pre">get_awaitable</span></code></p> <div class="versionadded"> <p><span class="versionmodified">3.5 版新加入.</span></p> </div> </dd></dl> <dl class="opcode"> <dt id="opcode-BEFORE_ASYNC_WITH"> <code class="descname">BEFORE_ASYNC_WITH</code><a class="headerlink" href="#opcode-BEFORE_ASYNC_WITH" title="本定義的永久連結">¶</a></dt> <dd><p>Resolves <code class="docutils literal notranslate"><span class="pre">__aenter__</span></code> and <code class="docutils literal notranslate"><span class="pre">__aexit__</span></code> from the object on top of the stack. Pushes <code class="docutils literal notranslate"><span class="pre">__aexit__</span></code> and result of <code class="docutils literal notranslate"><span class="pre">__aenter__()</span></code> to the stack.</p> <div class="versionadded"> <p><span class="versionmodified">3.5 版新加入.</span></p> </div> </dd></dl> <dl class="opcode"> <dt id="opcode-SETUP_ASYNC_WITH"> <code class="descname">SETUP_ASYNC_WITH</code><a class="headerlink" href="#opcode-SETUP_ASYNC_WITH" title="本定義的永久連結">¶</a></dt> <dd><p>Creates a new frame object.</p> <div class="versionadded"> <p><span class="versionmodified">3.5 版新加入.</span></p> </div> </dd></dl> <p><strong>Miscellaneous opcodes</strong></p> <dl class="opcode"> <dt id="opcode-PRINT_EXPR"> <code class="descname">PRINT_EXPR</code><a class="headerlink" href="#opcode-PRINT_EXPR" title="本定義的永久連結">¶</a></dt> <dd><p>Implements the expression statement for the interactive mode. TOS is removed from the stack and printed. In non-interactive mode, an expression statement is terminated with <a class="reference internal" href="#opcode-POP_TOP"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">POP_TOP</span></code></a>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BREAK_LOOP"> <code class="descname">BREAK_LOOP</code><a class="headerlink" href="#opcode-BREAK_LOOP" title="本定義的永久連結">¶</a></dt> <dd><p>Terminates a loop due to a <a class="reference internal" href="../reference/simple_stmts.html#break"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">break</span></code></a> statement.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-CONTINUE_LOOP"> <code class="descname">CONTINUE_LOOP</code><span class="sig-paren">(</span><em>target</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-CONTINUE_LOOP" title="本定義的永久連結">¶</a></dt> <dd><p>Continues a loop due to a <a class="reference internal" href="../reference/simple_stmts.html#continue"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">continue</span></code></a> statement. <em>target</em> is the address to jump to (which should be a <a class="reference internal" href="#opcode-FOR_ITER"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">FOR_ITER</span></code></a> instruction).</p> </dd></dl> <dl class="opcode"> <dt id="opcode-SET_ADD"> <code class="descname">SET_ADD</code><span class="sig-paren">(</span><em>i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-SET_ADD" title="本定義的永久連結">¶</a></dt> <dd><p>Calls <code class="docutils literal notranslate"><span class="pre">set.add(TOS1[-i],</span> <span class="pre">TOS)</span></code>. Used to implement set comprehensions.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-LIST_APPEND"> <code class="descname">LIST_APPEND</code><span class="sig-paren">(</span><em>i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LIST_APPEND" title="本定義的永久連結">¶</a></dt> <dd><p>Calls <code class="docutils literal notranslate"><span class="pre">list.append(TOS[-i],</span> <span class="pre">TOS)</span></code>. Used to implement list comprehensions.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-MAP_ADD"> <code class="descname">MAP_ADD</code><span class="sig-paren">(</span><em>i</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-MAP_ADD" title="本定義的永久連結">¶</a></dt> <dd><p>Calls <code class="docutils literal notranslate"><span class="pre">dict.setitem(TOS1[-i],</span> <span class="pre">TOS,</span> <span class="pre">TOS1)</span></code>. Used to implement dict comprehensions.</p> <div class="versionadded"> <p><span class="versionmodified">3.1 版新加入.</span></p> </div> </dd></dl> <p>For all of the <a class="reference internal" href="#opcode-SET_ADD"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">SET_ADD</span></code></a>, <a class="reference internal" href="#opcode-LIST_APPEND"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">LIST_APPEND</span></code></a> and <a class="reference internal" href="#opcode-MAP_ADD"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">MAP_ADD</span></code></a> instructions, while the added value or key/value pair is popped off, the container object remains on the stack so that it is available for further iterations of the loop.</p> <dl class="opcode"> <dt id="opcode-RETURN_VALUE"> <code class="descname">RETURN_VALUE</code><a class="headerlink" href="#opcode-RETURN_VALUE" title="本定義的永久連結">¶</a></dt> <dd><p>Returns with TOS to the caller of the function.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-YIELD_VALUE"> <code class="descname">YIELD_VALUE</code><a class="headerlink" href="#opcode-YIELD_VALUE" title="本定義的永久連結">¶</a></dt> <dd><p>Pops TOS and yields it from a <a class="reference internal" href="../glossary.html#term-generator"><span class="xref std std-term">generator</span></a>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-YIELD_FROM"> <code class="descname">YIELD_FROM</code><a class="headerlink" href="#opcode-YIELD_FROM" title="本定義的永久連結">¶</a></dt> <dd><p>Pops TOS and delegates to it as a subiterator from a <a class="reference internal" href="../glossary.html#term-generator"><span class="xref std std-term">generator</span></a>.</p> <div class="versionadded"> <p><span class="versionmodified">3.3 版新加入.</span></p> </div> </dd></dl> <dl class="opcode"> <dt id="opcode-SETUP_ANNOTATIONS"> <code class="descname">SETUP_ANNOTATIONS</code><a class="headerlink" href="#opcode-SETUP_ANNOTATIONS" title="本定義的永久連結">¶</a></dt> <dd><p>Checks whether <code class="docutils literal notranslate"><span class="pre">__annotations__</span></code> is defined in <code class="docutils literal notranslate"><span class="pre">locals()</span></code>, if not it is set up to an empty <code class="docutils literal notranslate"><span class="pre">dict</span></code>. This opcode is only emitted if a class or module body contains <a class="reference internal" href="../glossary.html#term-variable-annotation"><span class="xref std std-term">variable annotations</span></a> statically.</p> <div class="versionadded"> <p><span class="versionmodified">3.6 版新加入.</span></p> </div> </dd></dl> <dl class="opcode"> <dt id="opcode-IMPORT_STAR"> <code class="descname">IMPORT_STAR</code><a class="headerlink" href="#opcode-IMPORT_STAR" title="本定義的永久連結">¶</a></dt> <dd><p>Loads all symbols not starting with <code class="docutils literal notranslate"><span class="pre">'_'</span></code> directly from the module TOS to the local namespace. The module is popped after loading all names. This opcode implements <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">module</span> <span class="pre">import</span> <span class="pre">*</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-POP_BLOCK"> <code class="descname">POP_BLOCK</code><a class="headerlink" href="#opcode-POP_BLOCK" title="本定義的永久連結">¶</a></dt> <dd><p>Removes one block from the block stack. Per frame, there is a stack of blocks, denoting nested loops, try statements, and such.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-POP_EXCEPT"> <code class="descname">POP_EXCEPT</code><a class="headerlink" href="#opcode-POP_EXCEPT" title="本定義的永久連結">¶</a></dt> <dd><p>Removes one block from the block stack. The popped block must be an exception handler block, as implicitly created when entering an except handler. In addition to popping extraneous values from the frame stack, the last three popped values are used to restore the exception state.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-END_FINALLY"> <code class="descname">END_FINALLY</code><a class="headerlink" href="#opcode-END_FINALLY" title="本定義的永久連結">¶</a></dt> <dd><p>Terminates a <a class="reference internal" href="../reference/compound_stmts.html#finally"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">finally</span></code></a> clause. The interpreter recalls whether the exception has to be re-raised, or whether the function returns, and continues with the outer-next block.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-LOAD_BUILD_CLASS"> <code class="descname">LOAD_BUILD_CLASS</code><a class="headerlink" href="#opcode-LOAD_BUILD_CLASS" title="本定義的永久連結">¶</a></dt> <dd><p>Pushes <code class="xref py py-func docutils literal notranslate"><span class="pre">builtins.__build_class__()</span></code> onto the stack. It is later called by <a class="reference internal" href="#opcode-CALL_FUNCTION"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">CALL_FUNCTION</span></code></a> to construct a class.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-SETUP_WITH"> <code class="descname">SETUP_WITH</code><span class="sig-paren">(</span><em>delta</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-SETUP_WITH" title="本定義的永久連結">¶</a></dt> <dd><p>This opcode performs several operations before a with block starts. First, it loads <a class="reference internal" href="../reference/datamodel.html#object.__exit__" title="object.__exit__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__exit__()</span></code></a> from the context manager and pushes it onto the stack for later use by <code class="xref std std-opcode docutils literal notranslate"><span class="pre">WITH_CLEANUP</span></code>. Then, <a class="reference internal" href="../reference/datamodel.html#object.__enter__" title="object.__enter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__enter__()</span></code></a> is called, and a finally block pointing to <em>delta</em> is pushed. Finally, the result of calling the enter method is pushed onto the stack. The next opcode will either ignore it (<a class="reference internal" href="#opcode-POP_TOP"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">POP_TOP</span></code></a>), or store it in (a) variable(s) (<a class="reference internal" href="#opcode-STORE_FAST"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_FAST</span></code></a>, <a class="reference internal" href="#opcode-STORE_NAME"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_NAME</span></code></a>, or <a class="reference internal" href="#opcode-UNPACK_SEQUENCE"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">UNPACK_SEQUENCE</span></code></a>).</p> <div class="versionadded"> <p><span class="versionmodified">3.2 版新加入.</span></p> </div> </dd></dl> <dl class="opcode"> <dt id="opcode-WITH_CLEANUP_START"> <code class="descname">WITH_CLEANUP_START</code><a class="headerlink" href="#opcode-WITH_CLEANUP_START" title="本定義的永久連結">¶</a></dt> <dd><p>Cleans up the stack when a <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> statement block exits. TOS is the context manager’s <a class="reference internal" href="../reference/datamodel.html#object.__exit__" title="object.__exit__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__exit__()</span></code></a> bound method. Below TOS are 1–3 values indicating how/why the finally clause was entered:</p> <ul class="simple"> <li>SECOND = <code class="docutils literal notranslate"><span class="pre">None</span></code></li> <li>(SECOND, THIRD) = (<code class="docutils literal notranslate"><span class="pre">WHY_{RETURN,CONTINUE}</span></code>), retval</li> <li>SECOND = <code class="docutils literal notranslate"><span class="pre">WHY_*</span></code>; no retval below it</li> <li>(SECOND, THIRD, FOURTH) = exc_info()</li> </ul> <p>In the last case, <code class="docutils literal notranslate"><span class="pre">TOS(SECOND,</span> <span class="pre">THIRD,</span> <span class="pre">FOURTH)</span></code> is called, otherwise <code class="docutils literal notranslate"><span class="pre">TOS(None,</span> <span class="pre">None,</span> <span class="pre">None)</span></code>. Pushes SECOND and result of the call to the stack.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-WITH_CLEANUP_FINISH"> <code class="descname">WITH_CLEANUP_FINISH</code><a class="headerlink" href="#opcode-WITH_CLEANUP_FINISH" title="本定義的永久連結">¶</a></dt> <dd><p>Pops exception type and result of 『exit』 function call from the stack.</p> <p>If the stack represents an exception, <em>and</em> the function call returns a 『true』 value, this information is 「zapped」 and replaced with a single <code class="docutils literal notranslate"><span class="pre">WHY_SILENCED</span></code> to prevent <a class="reference internal" href="#opcode-END_FINALLY"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">END_FINALLY</span></code></a> from re-raising the exception. (But non-local gotos will still be resumed.)</p> </dd></dl> <p>All of the following opcodes use their arguments.</p> <dl class="opcode"> <dt id="opcode-STORE_NAME"> <code class="descname">STORE_NAME</code><span class="sig-paren">(</span><em>namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-STORE_NAME" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">name</span> <span class="pre">=</span> <span class="pre">TOS</span></code>. <em>namei</em> is the index of <em>name</em> in the attribute <code class="xref py py-attr docutils literal notranslate"><span class="pre">co_names</span></code> of the code object. The compiler tries to use <a class="reference internal" href="#opcode-STORE_FAST"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_FAST</span></code></a> or <a class="reference internal" href="#opcode-STORE_GLOBAL"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_GLOBAL</span></code></a> if possible.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-DELETE_NAME"> <code class="descname">DELETE_NAME</code><span class="sig-paren">(</span><em>namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-DELETE_NAME" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">del</span> <span class="pre">name</span></code>, where <em>namei</em> is the index into <code class="xref py py-attr docutils literal notranslate"><span class="pre">co_names</span></code> attribute of the code object.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-UNPACK_SEQUENCE"> <code class="descname">UNPACK_SEQUENCE</code><span class="sig-paren">(</span><em>count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-UNPACK_SEQUENCE" title="本定義的永久連結">¶</a></dt> <dd><p>Unpacks TOS into <em>count</em> individual values, which are put onto the stack right-to-left.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-UNPACK_EX"> <code class="descname">UNPACK_EX</code><span class="sig-paren">(</span><em>counts</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-UNPACK_EX" title="本定義的永久連結">¶</a></dt> <dd><p>Implements assignment with a starred target: Unpacks an iterable in TOS into individual values, where the total number of values can be smaller than the number of items in the iterable: one of the new values will be a list of all leftover items.</p> <p>The low byte of <em>counts</em> is the number of values before the list value, the high byte of <em>counts</em> the number of values after it. The resulting values are put onto the stack right-to-left.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-STORE_ATTR"> <code class="descname">STORE_ATTR</code><span class="sig-paren">(</span><em>namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-STORE_ATTR" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">TOS.name</span> <span class="pre">=</span> <span class="pre">TOS1</span></code>, where <em>namei</em> is the index of name in <code class="xref py py-attr docutils literal notranslate"><span class="pre">co_names</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-DELETE_ATTR"> <code class="descname">DELETE_ATTR</code><span class="sig-paren">(</span><em>namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-DELETE_ATTR" title="本定義的永久連結">¶</a></dt> <dd><p>Implements <code class="docutils literal notranslate"><span class="pre">del</span> <span class="pre">TOS.name</span></code>, using <em>namei</em> as index into <code class="xref py py-attr docutils literal notranslate"><span class="pre">co_names</span></code>.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-STORE_GLOBAL"> <code class="descname">STORE_GLOBAL</code><span class="sig-paren">(</span><em>namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-STORE_GLOBAL" title="本定義的永久連結">¶</a></dt> <dd><p>Works as <a class="reference internal" href="#opcode-STORE_NAME"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_NAME</span></code></a>, but stores the name as a global.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-DELETE_GLOBAL"> <code class="descname">DELETE_GLOBAL</code><span class="sig-paren">(</span><em>namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-DELETE_GLOBAL" title="本定義的永久連結">¶</a></dt> <dd><p>Works as <a class="reference internal" href="#opcode-DELETE_NAME"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">DELETE_NAME</span></code></a>, but deletes a global name.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-LOAD_CONST"> <code class="descname">LOAD_CONST</code><span class="sig-paren">(</span><em>consti</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_CONST" title="本定義的永久連結">¶</a></dt> <dd><p>Pushes <code class="docutils literal notranslate"><span class="pre">co_consts[consti]</span></code> onto the stack.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-LOAD_NAME"> <code class="descname">LOAD_NAME</code><span class="sig-paren">(</span><em>namei</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-LOAD_NAME" title="本定義的永久連結">¶</a></dt> <dd><p>Pushes the value associated with <code class="docutils literal notranslate"><span class="pre">co_names[namei]</span></code> onto the stack.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BUILD_TUPLE"> <code class="descname">BUILD_TUPLE</code><span class="sig-paren">(</span><em>count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_TUPLE" title="本定義的永久連結">¶</a></dt> <dd><p>Creates a tuple consuming <em>count</em> items from the stack, and pushes the resulting tuple onto the stack.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BUILD_LIST"> <code class="descname">BUILD_LIST</code><span class="sig-paren">(</span><em>count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_LIST" title="本定義的永久連結">¶</a></dt> <dd><p>Works as <a class="reference internal" href="#opcode-BUILD_TUPLE"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_TUPLE</span></code></a>, but creates a list.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BUILD_SET"> <code class="descname">BUILD_SET</code><span class="sig-paren">(</span><em>count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_SET" title="本定義的永久連結">¶</a></dt> <dd><p>Works as <a class="reference internal" href="#opcode-BUILD_TUPLE"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_TUPLE</span></code></a>, but creates a set.</p> </dd></dl> <dl class="opcode"> <dt id="opcode-BUILD_MAP"> <code class="descname">BUILD_MAP</code><span class="sig-paren">(</span><em>count</em><span class="sig-paren">)</span><a class="headerlink" href="#opcode-BUILD_MAP" title="本定義的永久連結">¶</a></dt> <dd><p>Pushes a new dictionary object onto the stack. Pops <code class="docutils literal notranslate"><span class="pre">2</span> <span class="pre">*</span> <span class="pre">count</span></code> items so that the dictionary holds <em>count</em> entries: <code class="docutils literal notranslate"><span class="pre">{...,</span> <span class="pre">TOS3:</span> <span class="pre">TOS2,</span> <span class="pre">TOS1:</span> <span class="pre">TOS}</span></code>.</p> <div class="versionchanged"> <p><span class="versionmodified">3.5 版更變: </span>The dictionary is created from stack items instead of creating an empty dictionary pre-sized to hold <em>count</em> items.</p> </div> |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |