summaryrefslogtreecommitdiff
path: root/Include/opcode.h
AgeCommit message (Collapse)AuthorLines
2009-05-25add a SETUP_WITH opcodeBenjamin Peterson-1/+3
It speeds up the with statement and correctly looks up the special methods involved.
2009-02-28Backport r69961 to trunk, replacing JUMP_IF_{TRUE,FALSE} withJeffrey Yasskin-3/+6
POP_JUMP_IF_{TRUE,FALSE} and JUMP_IF_{TRUE,FALSE}_OR_POP. This avoids executing a POP_TOP on each conditional and sometimes allows the peephole optimizer to skip a JUMP_ABSOLUTE entirely. It speeds up list comprehensions significantly.
2008-12-17Issue #2183: Simplify and optimize bytecode for list comprehensions.Antoine Pitrou-1/+1
2007-12-18Speed-up dictionary constructor by about 10%.Raymond Hettinger-0/+1
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
2007-07-11Fix #1752132: wrong comment in opcode description.Georg Brandl-1/+1
2006-02-27PEP 343 -- the with-statement.Guido van Rossum-2/+1
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).
2004-06-21Install two code generation optimizations that depend on NOP.Raymond Hettinger-0/+1
Reduces the cost of "not" to almost zero.
2004-03-07SF patch #910929: Optimize list comprehensionsRaymond Hettinger-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.
2003-04-24Revert the previous enhancement to the bytecode optimizer.Raymond Hettinger-2/+0
The additional code complexity and new NOP opcode were not worth it.
2003-04-22Improved the bytecode optimizer.Raymond Hettinger-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.
2002-08-30Further SET_LINENO reomval fixes. See comments in patch #587933.Michael W. Hudson-3/+0
Use a slightly different strategy to determine when not to call the line trace function. This removes the need for the RETURN_NONE opcode, so that's gone again. Update docs and comments to match. Thanks to Neal and Armin! Also add a test suite. This should have come with the original patch...
2002-08-15This is my patchMichael W. Hudson-2/+3
[ 587993 ] SET_LINENO killer Remove SET_LINENO. Tracing is now supported by inspecting co_lnotab. Many sundry changes to document and adapt to this change.
2002-06-13The opcode FOR_LOOP no longer exists.Guido van Rossum-1/+0
2002-01-01Patch #494783: Rename cmp_op enumerators.Martin v. Löwis-3/+3
2001-08-08Implement PEP 238 in its (almost) full glory.Guido van Rossum-0/+4
This introduces: - A new operator // that means floor division (the kind of division where 1/2 is 0). - The "future division" statement ("from __future__ import division) which changes the meaning of the / operator to implement "true division" (where 1/2 is 0.5). - New overloadable operators __truediv__ and __floordiv__. - New slots in the PyNumberMethods struct for true and floor division, new abstract APIs for them, new opcodes, and so on. I emphasize that without the future division statement, the semantics of / will remain unchanged until Python 3.0. Not yet implemented are warnings (default off) when / is used with int or long arguments. This has been on display since 7/31 as SF patch #443474. Flames to /dev/null.
2001-06-18Merging the gen-branch into the main line, at Guido's direction. Yay!Tim Peters-0/+1
Bugfix candidate in inspect.py: it was referencing "self" outside of a method.
2001-04-20Iterators phase 1. This comprises:Guido van Rossum-0/+2
new slot tp_iter in type object, plus new flag Py_TPFLAGS_HAVE_ITER new C API PyObject_GetIter(), calls tp_iter new builtin iter(), with two forms: iter(obj), and iter(function, sentinel) new internal object types iterobject and calliterobject new exception StopIteration new opcodes for "for" loops, GET_ITER and FOR_ITER (also supported by dis.py) new magic number for .pyc files new special method for instances: __iter__() returns an iterator iteration over dictionaries: "for x in dict" iterates over the keys iteration over files: "for x in file" iterates over lines TODO: documentation test suite decide whether to use a different way to spell iter(function, sentinal) decide whether "for key in dict" is a good idea use iterators in map/filter/reduce, min/max, and elsewhere (in/not in?) speed tuning (make next() a slot tp_next???)
2001-02-01Allow 'continue' inside 'try' clauseJeremy Hylton-0/+1
SF patch 102989 by Thomas Wouters
2001-01-25PEP 227 implementationJeremy Hylton-5/+5
The majority of the changes are in the compiler. The mainloop changes primarily to implement the new opcodes and to pass a function's closure to eval_code2(). Frames and functions got new slots to hold the closure. Include/compile.h Add co_freevars and co_cellvars slots to code objects. Update PyCode_New() to take freevars and cellvars as arguments Include/funcobject.h Add func_closure slot to function objects. Add GetClosure()/SetClosure() functions (and corresponding macros) for getting at the closure. Include/frameobject.h PyFrame_New() now takes a closure. Include/opcode.h Add four new opcodes: MAKE_CLOSURE, LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF. Remove comment about old requirement for opcodes to fit in 7 bits. compile.c Implement changes to code objects for co_freevars and co_cellvars. Modify symbol table to use st_cur_name (string object for the name of the current scope) and st_cur_children (list of nested blocks). Also define st_nested, which might more properly be called st_cur_nested. Add several DEF_XXX flags to track def-use information for free variables. New or modified functions of note: com_make_closure(struct compiling *, PyCodeObject *) Emit LOAD_CLOSURE opcodes as needed to pass cells for free variables into nested scope. com_addop_varname(struct compiling *, int, char *) Emits opcodes for LOAD_DEREF and STORE_DEREF. get_ref_type(struct compiling *, char *name) Return NAME_CLOSURE if ref type is FREE or CELL symtable_load_symbols(struct compiling *) Decides what variables are cell or free based on def-use info. Can now raise SyntaxError if nested scopes are mixed with exec or from blah import *. make_scope_info(PyObject *, PyObject *, int, int) Helper functions for symtable scope stack. symtable_update_free_vars(struct symtable *) After a code block has been analyzed, it must check each of its children for free variables that are not defined in the block. If a variable is free in a child and not defined in the parent, then it is defined by block the enclosing the current one or it is a global. This does the right logic. symtable_add_use() is now a macro for symtable_add_def() symtable_assign(struct symtable *, node *) Use goto instead of for (;;) Fixed bug in symtable where name of keyword argument in function call was treated as assignment in the scope of the call site. Ex: def f(): g(a=2) # a was considered a local of f ceval.c eval_code2() now take one more argument, a closure. Implement LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF, MAKE_CLOSURE> Also: When name error occurs for global variable, report that the name was global in the error mesage. Objects/frameobject.c Initialize f_closure to be a tuple containing space for cellvars and freevars. f_closure is NULL if neither are present. Objects/funcobject.c Add support for func_closure. Python/import.c Change the magic number. Python/marshal.c Track changes to code objects.
2001-01-17Rich comparisons: ensure that LT == Py_LT, etc.Guido van Rossum-1/+2
2000-09-01REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum-9/+0
This should match the situation in the 1.6b1 tree.
2000-08-24The real suport for augmented assignment: new opcodes, new PyNumber andThomas Wouters-3/+13
PySequence methods and functions, new tokens.
2000-08-24Charles G. Waldman <cgw@fnal.gov>:Fred Drake-0/+3
Add the EXTENDED_ARG opcode to the virtual machine, allowing 32-bit arguments to opcodes instead of being forced to stick to the 16-bit limit. This is especially useful for machine-generated code, which can be too long for the SET_LINENO parameter to fit into 16 bits. This closes the implementation portion of SourceForge patch #100893.
2000-08-21PEP 214, Extended print Statement, has been accepted by the BDFL.Barry Warsaw-0/+2
This adds the two new opcodes to support this feature: PRINT_ITEM_TO, PRINT_NEWLINE_TO.
2000-08-17Apply SF patch #101135, adding 'import module as m' and 'from module importThomas Wouters-1/+1
name as n'. By doing some twists and turns, "as" is not a reserved word. There is a slight change in semantics for 'from module import name' (it will now honour the 'global' keyword) but only in cases that are explicitly undocumented.
2000-08-11Merge UNPACK_LIST and UNPACK_TUPLE into a single UNPACK_SEQUENCE, since theyThomas Wouters-2/+2
did the same anyway. I'm not sure what to do with Tools/compiler/compiler/* -- that isn't part of distutils, is it ? Should it try to be compatible with old bytecode version ?
2000-06-30Change copyright notice - 2nd try.Guido van Rossum-6/+0
2000-06-30Change copyright notice.Guido van Rossum-21/+6
2000-03-29remove reference to CALL_FUNCTION_STAR in commentJeremy Hylton-1/+1
2000-03-28slightly modified version of Greg Ewing's extended call syntax patchJeremy Hylton-0/+7
executive summary: Instead of typing 'apply(f, args, kwargs)' you can type 'f(*arg, **kwargs)'. Some file-by-file details follow. Grammar/Grammar: simplify varargslist, replacing '*' '*' with '**' add * & ** options to arglist Include/opcode.h & Lib/dis.py: define three new opcodes CALL_FUNCTION_VAR CALL_FUNCTION_KW CALL_FUNCTION_VAR_KW Python/ceval.c: extend TypeError "keyword parameter redefined" message to include the name of the offending keyword reindent CALL_FUNCTION using four spaces add handling of sequences and dictionaries using extend calls fix function import_from to use PyErr_Format
1998-07-07Get rid of some obsolete opcodes.Guido van Rossum-5/+0
1997-05-09Get rid of obsolete ACCESS_MODE opcode.Guido van Rossum-1/+0
1996-10-25New permission notice, includes CNRI.Guido van Rossum-12/+19
1996-07-30Added BUILD_SLICE opcode.Guido van Rossum-0/+1
1996-01-12changes for ** (power) operatorGuido van Rossum-0/+2
1995-07-18keyword arguments and faster function callsGuido van Rossum-6/+4
1995-07-07new opcodes RAISE_VARARGS, CALL_FUNCTIONGuido van Rossum-0/+8
1995-01-04Added 1995 copyright.Guido van Rossum-2/+2
object.h: made sizes and refcnts signed ints. stringobject.h: make getstrsize() signed int. methodobject.h: add METH_VARARGS and METH_FREENAME flag bit definitions.
1994-08-01Merge alpha100 branch back to main trunkGuido van Rossum-1/+3
1993-10-18* bltinmodule.c: removed exec() built-in function.Guido van Rossum-0/+2
* Grammar: add exec statement; allow testlist in expr statement. * ceval.c, compile.c, opcode.h: support exec statement; avoid optimizing locals when it is used * fileobject.{c,h}: add getfilename() internal function.
1993-07-28* Added support for X11 modules.Guido van Rossum-0/+11
* Makefile: change location of FORMS library. * posixmodule.c: turn #if 0 into #ifdef MSDOS (stuff in unistd.h or not) * Almost all .h files: added CPP magic to avoid duplicate inclusions and to support inclusion from C++.
1993-05-19Several changes in one:Guido van Rossum-0/+1
(1) dictionaries/mappings now have attributes values() and items() as well as keys(); at the C level, use the new function mappinggetnext() to iterate over a dictionary. (2) "class C(): ..." is now illegal; you must write "class C: ...". (3) Class objects now know their own name (finally!); and minor improvements to the way how classes, functions and methods are represented as strings. (4) Added an "access" statement and semantics. (This is still experimental -- as long as you don't use the keyword 'access' nothing should be changed.)
1993-03-30Changes to speed up local variables enormously, by avoiding dictionaryGuido van Rossum-8/+6
lookup (opcode.h, ceval.[ch], compile.c, frameobject.[ch], pythonrun.c, import.c). The .pyc MAGIC number is changed again. Added get_menu_text to flmodule.
1993-03-29* Changed all copyright messages to include 1993.Guido van Rossum-2/+6
* Stubs for faster implementation of local variables (not yet finished) * Added function name to code object. Print it for code and function objects. THIS MAKES THE .PYC FILE FORMAT INCOMPATIBLE (the version number has changed accordingly) * Print address of self for built-in methods * New internal functions getattro and setattro (getattr/setattr with string object arg) * Replaced "dictobject" with more powerful "mappingobject" * New per-type functio tp_hash to implement arbitrary object hashing, and hashobject() to interface to it * Added built-in functions hash(v) and hasattr(v, 'name') * classobject: made some functions static that accidentally weren't; added __hash__ special instance method to implement hash() * Added proper comparison for built-in methods and functions
1992-04-05Copyright for 1992 addedGuido van Rossum-1/+1
1992-01-14Added UNPACK_VARARG.Guido van Rossum-0/+1
1991-12-16Added UNPACK_ARG.Guido van Rossum-1/+3
1991-12-10Added _GLOBAL opcodes.Guido van Rossum-0/+2
1991-10-24Added shift and mask ops.Guido van Rossum-0/+8
1991-04-04Added opcodes to load local/global variablesGuido van Rossum-0/+3