summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* Backport r69961 to trunk, replacing JUMP_IF_{TRUE,FALSE} withJeffrey Yasskin2009-02-281-53/+33
| | | | | | 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.
* more flags which only work for function blocksBenjamin Peterson2009-01-311-6/+4
|
* add explanatory commentBenjamin Peterson2009-01-311-0/+2
|
* #4077: No need to append \n when calling Py_FatalErrorAmaury Forgeot d'Arc2009-01-171-1/+1
| | | | + fix a declaration to make it match the one in pythonrun.h
* #4748 lambda generators shouldn't return valuesBenjamin Peterson2008-12-271-1/+6
|
* Issue #2183: Simplify and optimize bytecode for list comprehensions.Antoine Pitrou2008-12-171-26/+7
|
* check for assignment to __debug__ during AST generationBenjamin Peterson2008-11-081-6/+0
| | | | Also, give assignment to None a better error message
* Merge in release25-maint r60793:Gregory P. Smith2008-06-111-4/+28
| | | | | | Added checks for integer overflows, contributed by Google. Some are only available if asserts are left in the code, in cases where they can't be triggered from Python code.
* This reverts r63675 based on the discussion in this thread:Gregory P. Smith2008-06-091-47/+47
| | | | | | | http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
* Renamed PyString to PyBytesChristian Heimes2008-05-261-47/+47
|
* Patch #2511: Give the "excepthandler" AST item proper attributes by making ↵Georg Brandl2008-03-301-7/+7
| | | | it a Sum.
* Fix a reference leak found by Georg, when compiling a class nested in ↵Amaury Forgeot d'Arc2008-03-281-0/+1
| | | | | | | | another class. Now "regrtest.py -R:: test_compile" is satisfied. Will backport.
* Patch #1810 by Thomas Lee, reviewed by myself:Georg Brandl2008-03-281-6/+14
| | | | | allow compiling Python AST objects into code objects in compile().
* Add a warning for code like:Neal Norwitz2008-03-151-0/+8
| | | | | | | | | | assert (0, 'message') An empty tuple does not create a warning. While questionable usage: assert (), 'message' should not display a warning. Tested manually. The warning message could be improved. Feel free to update it.
* Speed up with statements by storing the __exit__ method on the stack instead ↵Nick Coghlan2008-03-071-14/+6
| | | | of in a temp variable (bumps the magic number for pyc files)
* Fix indentationNeal Norwitz2008-02-251-1/+1
|
* Patch #1759: Backport of PEP 3129 class decoratorsChristian Heimes2008-02-231-2/+11
| | | | with some help from Georg
* Cast a struct to a void pointer so as to do a type-safe pointer comparisonBrett Cannon2008-02-071-3/+3
| | | | (mistmatch found by clang).
* Change r60575 broke test_compile:Amaury Forgeot d'Arc2008-02-051-0/+3
| | | | there is no need to emit co_lnotab item when both offsets are zeros.
* #1750076: Debugger did not step on every iteration of a while statement.Amaury Forgeot d'Arc2008-02-041-14/+15
| | | | | | | | | | | | The mapping between bytecode offsets and source lines (lnotab) did not contain an entry for the beginning of the loop. Now it does, and the lnotab can be a bit larger: in particular, several statements on the same line generate several entries. However, this does not bother the settrace function, which will trigger only one 'line' event. The lnotab seems to be exactly the same as with python2.4.
* Issue #1678380. Fix a bug that identifies 0j and -0j when they appearMark Dickinson2008-01-311-12/+47
| | | | | in the same code unit. The fix is essentially the same as the fix for a previous bug identifying 0. and -0.
* static PyObject* variables should use PyString_InternFromString() instead of ↵Christian Heimes2008-01-281-2/+2
| | | | PyObject_FromString() to store a python string in a function level static var.
* #1920: when considering a block starting by "while 0", the compiler ↵Amaury Forgeot d'Arc2008-01-241-1/+4
| | | | | | | | | | | | | | | | | optimized the whole construct away, even when an 'else' clause is present:: while 0: print("no") else: print("yes") did not generate any code at all. Now the compiler emits the 'else' block, like it already does for 'if' statements. Will backport.
* Add commentsRaymond Hettinger2007-12-201-3/+3
|
* Bigger range for non-extended opargs.Raymond Hettinger2007-12-191-1/+1
|
* Zap a duplicate lineRaymond Hettinger2007-12-191-1/+0
|
* Give meaning to the oparg for BUILD_MAP: estimated size of the dictionary.Raymond Hettinger2007-12-181-4/+2
| | | | | | | | | | | 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.
* Speed-up dictionary constructor by about 10%.Raymond Hettinger2007-12-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix #1169: remove docstrings in functions for -OO.Georg Brandl2007-09-191-1/+1
|
* Revert compile.c changes that shouldn't have been included in previous checkinNick Coghlan2007-08-251-7/+2
|
* Revert misguided attempt at fixing incompatibility between -m and -i ↵Nick Coghlan2007-08-251-2/+7
| | | | switches (better fix coming soon)
* Fix compile.c so that it records 0.0 and -0.0 as separate constants in a codeAlex Martelli2007-08-221-1/+14
| | | | | object's co_consts tuple; add a test to show that the previous behavior (where these two constants were "collapsed" into one) causes serious malfunctioning.
* Bug #1722484: remove docstrings again when running with -OO.Georg Brandl2007-06-011-1/+2
|
* tabifyJeremy Hylton2007-02-271-34/+34
| | | | | Note that ast.c still has a mix of tabs and spaces, because it attempts to use four-space indents for more of the new code.
* Fix long-standing bug in name mangling for package importsJeremy Hylton2007-02-271-2/+12
| | | | Reported by Mike Verdone.
* Update comments, remove commented out code.Neal Norwitz2006-10-291-87/+31
| | | | | Move assembler structure next to assembler code to make it easier to move it to a separate file.
* Clean up a leftover from old listcomp generation code.Georg Brandl2006-10-291-7/+1
|
* Fix bug #1565514, SystemError not raised on too many nested blocks.Neal Norwitz2006-10-281-1/+4
| | | | | | | It seems like this should be a different error than SystemError, but I don't have any great ideas and SystemError was raised in 2.4 and earlier. Will backport.
* Fix for SF bug 1569998: break permitted inside try.Jeremy Hylton2006-10-041-1/+13
| | | | | | | | The compiler was checking that there was something on the fblock stack, but not that there was a loop on the stack. Fixed that and added a test for the specific syntax error. Bug fix candidate.
* Patch #1542451: disallow continue anywhere under a finallyNeal Norwitz2006-08-211-4/+9
| | | | | | I'm undecided if this should be backported to 2.5 or 2.5.1. Armin suggested to wait (I'm of the same opinion). Thomas W thinks it's fine to go in 2.5.
* Add assert to make Klocwork happy (#276)Neal Norwitz2006-08-211-0/+1
|
* Move peephole optimizer to separate file.Jeremy Hylton2006-08-211-608/+1
|
* Even though _Py_Mangle() isn't truly public anyone can call it andNeal Norwitz2006-08-121-2/+2
| | | | | | | | | | there was no verification that privateobj was a PyString. If it wasn't a string, this could have allowed a NULL pointer to creep in below and crash. I wonder if this should be PyString_CheckExact? Must identifiers be strings or can they be subclasses? Klocwork #275
* Bug #1333982: string/number constants were inappropriately storedNeal Norwitz2006-08-041-2/+4
| | | | | in the byte code and co_consts even if they were not used, ie immediately popped off the stack.
* Bug #1191458: tracing over for loops now produces a line eventNeal Norwitz2006-08-041-7/+46
| | | | | | | | | | | | on each iteration. I'm not positive this is the best way to handle this. I'm also not sure that there aren't other cases where the lnotab is generated incorrectly. It would be great if people that use pdb or tracing could test heavily. Also: * Remove dead/duplicated code that wasn't used/necessary because we already handled the docstring prior to entering the loop. * add some debugging code into the compiler (#if 0'd out).
* Add some asserts and update commentsNeal Norwitz2006-07-301-0/+1
|
* If the for loop isn't entered, entryblock will be NULL. If passedNeal Norwitz2006-07-231-0/+2
| | | | | | to stackdepth_walk it will be dereffed. Not sure if I found with failmalloc or Klockwork #55.
* Fix more memory allocation issues found with failmalloc.Neal Norwitz2006-07-221-13/+23
|
* Handle more memory allocation failures without crashing.Neal Norwitz2006-07-211-0/+9
|
* Bug #1512814, Fix incorrect lineno's when code within a functionNeal Norwitz2006-07-161-5/+6
| | | | had more than 255 blank lines. Byte codes need to go first, line #s second.