summaryrefslogtreecommitdiffstats
path: root/Lib/opcode.py
Commit message (Collapse)AuthorAgeFilesLines
* Issue #11823: disassembly now shows argument counts on calls with keyword argsAlexander Belopolsky2012-06-071-1/+6
|
* Implement PEP 380 - 'yield from' (closes #11682)Nick Coghlan2012-01-131-0/+1
|
* excise the remains of STOP_CODE, which hasn't done anything useful for yearsBenjamin Peterson2011-07-181-1/+0
|
* #4617: Previously it was illegal to delete a name from the localAmaury Forgeot d'Arc2010-09-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | namespace if it occurs as a free variable in a nested block. This limitation of the compiler has been lifted, and a new opcode introduced (DELETE_DEREF). This sample was valid in 2.6, but fails to compile in 3.x without this change:: >>> def f(): ... def print_error(): ... print(e) ... try: ... something ... except Exception as e: ... print_error() ... # implicit "del e" here This sample has always been invalid in Python, and now works:: >>> def outer(x): ... def inner(): ... return x ... inner() ... del x There is no need to bump the PYC magic number: the new opcode is used for code that did not compile before.
* Issue #9225: Remove the ROT_FOUR and DUP_TOPX opcode, the latter replacedAntoine Pitrou2010-09-041-2/+1
| | | | | by the new (and simpler) DUP_TOP_TWO. Performance isn't changed, but our bytecode is a bit simplified. Patch by Demur Rumed.
* Merged revisions 72912,72920,72940 via svnmerge fromBenjamin Peterson2009-06-281-2/+4
| | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r72912 | benjamin.peterson | 2009-05-25 08:13:44 -0500 (Mon, 25 May 2009) | 5 lines add a SETUP_WITH opcode It speeds up the with statement and correctly looks up the special methods involved. ........ r72920 | benjamin.peterson | 2009-05-25 15:12:57 -0500 (Mon, 25 May 2009) | 1 line take into account the fact that SETUP_WITH pushes a finally block ........ r72940 | benjamin.peterson | 2009-05-26 07:49:59 -0500 (Tue, 26 May 2009) | 1 line teach the peepholer about SETUP_WITH ........
* http://bugs.python.org/issue4715Jeffrey Yasskin2009-02-251-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch by Antoine Pitrou optimizes the bytecode for conditional branches by merging the following "POP_TOP" instruction into the conditional jump. For example, the list comprehension "[x for x in l if not x]" produced the following bytecode: 1 0 BUILD_LIST 0 3 LOAD_FAST 0 (.0) >> 6 FOR_ITER 23 (to 32) 9 STORE_FAST 1 (x) 12 LOAD_FAST 1 (x) 15 JUMP_IF_TRUE 10 (to 28) 18 POP_TOP 19 LOAD_FAST 1 (x) 22 LIST_APPEND 2 25 JUMP_ABSOLUTE 6 >> 28 POP_TOP 29 JUMP_ABSOLUTE 6 >> 32 RETURN_VALUE but after the patch it produces the following bytecode: 1 0 BUILD_LIST 0 3 LOAD_FAST 0 (.0) >> 6 FOR_ITER 18 (to 27) 9 STORE_FAST 1 (x) 12 LOAD_FAST 1 (x) 15 POP_JUMP_IF_TRUE 6 18 LOAD_FAST 1 (x) 21 LIST_APPEND 2 24 JUMP_ABSOLUTE 6 >> 27 RETURN_VALUE Notice that not only the code is shorter, but the conditional jump (POP_JUMP_IF_TRUE) jumps right to the start of the loop instead of going through the JUMP_ABSOLUTE at the end. "continue" statements are helped similarly. Furthermore, the old jump opcodes (JUMP_IF_FALSE, JUMP_IF_TRUE) have been replaced by two new opcodes: - JUMP_IF_TRUE_OR_POP, which jumps if true and pops otherwise - JUMP_IF_FALSE_OR_POP, which jumps if false and pops otherwise
* Merged revisions 67818 via svnmerge fromAntoine Pitrou2008-12-181-2/+5
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r67818 | antoine.pitrou | 2008-12-17 01:38:28 +0100 (mer., 17 déc. 2008) | 3 lines Issue #2183: Simplify and optimize bytecode for list comprehensions. ........
* Remove MAKE_BYTES which is a leftover from the mutable byte literal time.Georg Brandl2008-07-201-1/+1
|
* #3021: Antoine Pitrou's Lexical exception handlersBenjamin Peterson2008-06-111-0/+1
|
* Add missing UNPACK_EX opcode.Thomas Wouters2008-03-181-1/+1
|
* Merged revisions 59541-59561 via svnmerge fromChristian Heimes2007-12-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r59544 | raymond.hettinger | 2007-12-18 01:13:45 +0100 (Tue, 18 Dec 2007) | 1 line Add more namedtuple() test cases. Neaten the code and comments. ........ r59545 | christian.heimes | 2007-12-18 04:38:03 +0100 (Tue, 18 Dec 2007) | 3 lines Fixed for #1601: IDLE not working correctly on Windows (Py30a2/IDLE30a1) Amaury's ideas works great. Should we build the Python core with WINVER=0x0500 and _WIN32_WINNT=0x0500, too? ........ r59546 | christian.heimes | 2007-12-18 10:00:13 +0100 (Tue, 18 Dec 2007) | 1 line Make it a bit easier to test Tcl/Tk and idle from a build dir. ........ r59547 | christian.heimes | 2007-12-18 10:12:10 +0100 (Tue, 18 Dec 2007) | 1 line Removed several unused files from the PCbuild9 directory. They are relics from the past. ........ r59548 | raymond.hettinger | 2007-12-18 19:26:18 +0100 (Tue, 18 Dec 2007) | 29 lines Speed-up dictionary constructor by about 10%. New opcode, STORE_MAP saves the compiler from awkward stack manipulations and specializes for dicts using PyDict_SetItem instead of PyObject_SetItem. Old disassembly: 0 BUILD_MAP 0 3 DUP_TOP 4 LOAD_CONST 1 (1) 7 ROT_TWO 8 LOAD_CONST 2 ('x') 11 STORE_SUBSCR 12 DUP_TOP 13 LOAD_CONST 3 (2) 16 ROT_TWO 17 LOAD_CONST 4 ('y') 20 STORE_SUBSCR New disassembly: 0 BUILD_MAP 0 3 LOAD_CONST 1 (1) 6 LOAD_CONST 2 ('x') 9 STORE_MAP 10 LOAD_CONST 3 (2) 13 LOAD_CONST 4 ('y') 16 STORE_MAP ........ r59549 | thomas.heller | 2007-12-18 20:00:34 +0100 (Tue, 18 Dec 2007) | 2 lines Issue #1642: Fix segfault in ctypes when trying to delete attributes. ........ r59551 | guido.van.rossum | 2007-12-18 21:10:42 +0100 (Tue, 18 Dec 2007) | 2 lines Issue #1645 by Alberto Bertogli. Fix a comment. ........ r59553 | raymond.hettinger | 2007-12-18 22:24:09 +0100 (Tue, 18 Dec 2007) | 12 lines Give meaning to the oparg for BUILD_MAP: estimated size of the dictionary. Allows dictionaries to be pre-sized (upto 255 elements) saving time lost to re-sizes with their attendant mallocs and re-insertions. Has zero effect on small dictionaries (5 elements or fewer), a slight benefit for dicts upto 22 elements (because they had to resize once anyway), and more benefit for dicts upto 255 elements (saving multiple resizes during the build-up and reducing the number of collisions on the first insertions). Beyond 255 elements, there is no addional benefit. ........ r59554 | christian.heimes | 2007-12-18 22:56:09 +0100 (Tue, 18 Dec 2007) | 1 line Fixed #1649: IDLE error: dictionary changed size during iteration ........ r59557 | raymond.hettinger | 2007-12-18 23:21:27 +0100 (Tue, 18 Dec 2007) | 1 line Simplify and speedup _asdict() for named tuples. ........ r59558 | christian.heimes | 2007-12-19 00:22:54 +0100 (Wed, 19 Dec 2007) | 3 lines Applied patch #1635: Float patch for inf and nan on Windows (and other platforms). The patch unifies float("inf") and repr(float("inf")) on all platforms. ........ r59559 | raymond.hettinger | 2007-12-19 00:51:15 +0100 (Wed, 19 Dec 2007) | 1 line Users demand iterable input for named tuples. The author capitulates. ........ r59560 | raymond.hettinger | 2007-12-19 01:21:06 +0100 (Wed, 19 Dec 2007) | 1 line Beef-up tests for dict literals ........ r59561 | raymond.hettinger | 2007-12-19 01:27:21 +0100 (Wed, 19 Dec 2007) | 1 line Zap a duplicate line ........
* Remove the simple slicing API. All slicing is now done with slice objects.Thomas Wouters2007-08-301-14/+0
|
* Hide list comp variables and support set comprehensionsNick Coghlan2007-04-151-0/+1
|
* Implement PEP 3115 -- new metaclass syntax and semantics.Guido van Rossum2007-03-181-2/+3
| | | | | | | The compiler package hasn't been updated yet; test_compiler.py fails. Otherwise all tests seem to be passing now. There are no occurrences of __metaclass__ left in the standard library. Docs have not been updated.
* Bytes literal.Thomas Wouters2007-02-231-0/+1
|
* * Remove PRINT_ITEM(_TO), PRINT_NEWLINE(_TO) opcodes.Georg Brandl2007-02-091-4/+1
| | | | | | | * Fix some docstrings and one Print -> print. * Fix test_{class,code,descrtut,dis,extcall,parser,popen,pkg,subprocess,syntax,traceback}. These were the ones that generated code with a print statement. In most remaining failing tests there's an issue with the soft space.
* Patch #1550800: make exec a function.Georg Brandl2006-09-061-1/+0
|
* SF patch 1547796 by Georg Brandl -- set literals.Guido van Rossum2006-08-281-6/+7
|
* Remove the UNARY_CONVERT opcode (was used for backticks). Also bumped up theBrett Cannon2006-08-251-1/+0
| | | | import MAGIC number.
* INPLACE_DIVIDE is no longer necessary (INPLACE_TRUE_DIVIDE is used).Neal Norwitz2006-03-171-1/+1
|
* Get rid of last vestiges of BINARY_DIVIDE.Neal Norwitz2006-03-161-1/+1
|
* PEP 343 -- the with-statement.Guido van Rossum2006-02-271-7/+2
| | | | | | | | | | | | | This was started by Mike Bland and completed by Guido (with help from Neal). This still needs a __future__ statement added; Thomas is working on Michael's patch for that aspect. There's a small amount of code cleanup and refactoring in ast.c, compile.c and ceval.c (I fixed the lltrace behavior when EXT_POP is used -- however I had to make lltrace a static global).
* Install two code generation optimizations that depend on NOP.Raymond Hettinger2004-06-211-0/+1
| | | | Reduces the cost of "not" to almost zero.
* SF patch #910929: Optimize list comprehensionsRaymond Hettinger2004-03-071-0/+1
| | | | | Add a new opcode, LIST_APPEND, and apply it to the code generation for list comprehensions. Reduces the per-loop overhead by about a third.
* Replace backticks with repr() or "%r"Walter Dörwald2004-02-121-1/+1
| | | | From SF patch #852334.
* Revert the previous enhancement to the bytecode optimizer.Raymond Hettinger2003-04-241-2/+0
| | | | The additional code complexity and new NOP opcode were not worth it.
* Improved the bytecode optimizer.Raymond Hettinger2003-04-221-0/+2
| | | | | | | | | | | | | | * Can now test for basic blocks. * Optimize inverted comparisions. * Optimize unary_not followed by a conditional jump. * Added a new opcode, NOP, to keep code size constant. * Applied NOP to previous transformations where appropriate. Note, the NOP would not be necessary if other functions were added to re-target jump addresses and update the co_lnotab mapping. That would yield slightly faster and cleaner bytecode at the expense of optimizer simplicity and of keeping it decoupled from the line-numbering structure.
* new opcode module - extract opcode definitions from dis.py - eventuallySkip Montanaro2003-02-271-0/+188
should be generated automatically