summaryrefslogtreecommitdiff
path: root/Python/compile.c
AgeCommit message (Collapse)AuthorLines
2009-11-28Issue #1678380: When distinguishing between -0.0 and 0.0 inMark Dickinson-26/+15
compiler_add_o, use copysign instead of examining the first and last bytes of the double. The latter method fails for little-endian ARM, OABI, where doubles are little-endian but with the words swapped.
2009-11-20turn goto into do while loopBenjamin Peterson-36/+31
2009-10-15Allow core Python build to succeed under WITHOUT_COMPLEX. The module build ↵Mark Dickinson-3/+6
stage still fails.
2009-10-14Issue #1754094: Improve the stack depth calculation in the compiler.Neil Schemenauer-12/+21
There should be no other effect than a small decrease in memory use. Patch by Christopher Tur Lesniewski-Laas.
2009-06-21remove tmpname support since it's no longer usedBenjamin Peterson-2/+0
2009-06-17remove unused 'encoding' member from the compiler structBenjamin Peterson-4/+0
2009-06-13when no module is given in a 'from' relative import, make ImportFrom.module NULLBenjamin Peterson-10/+18
2009-05-29Fix nearly all compilation warnings under Apple gcc-4.0. Tested with OPT="-gJeffrey Yasskin-12/+0
-Wall -Wstrict-prototypes -Werror" in both --with-pydebug mode and --without. There's still a batch of non-prototype warnings in Xlib.h that I don't know how to fix.
2009-05-25take into account the fact that SETUP_WITH pushes a finally blockBenjamin Peterson-1/+1
2009-05-25add a SETUP_WITH opcodeBenjamin Peterson-56/+9
It speeds up the with statement and correctly looks up the special methods involved.
2009-05-23Issue #6042:Jeffrey Yasskin-51/+3
lnotab-based tracing is very complicated and isn't documented very well. There were at least 3 comment blocks purporting to document co_lnotab, and none did a very good job. This patch unifies them into Objects/lnotab_notes.txt which tries to completely capture the current state of affairs. I also discovered that we've attached 2 layers of patches to the basic tracing scheme. The first layer avoids jumping to instructions that don't start a line, to avoid problems in if statements and while loops. The second layer discovered that jumps backward do need to trace at instructions that don't start a line, so it added extra lnotab entries for 'while' and 'for' loops, and added a special case for backward jumps within the same line. I replaced these patches by just treating forward and backward jumps differently.
2009-02-28Backport r69961 to trunk, replacing JUMP_IF_{TRUE,FALSE} withJeffrey Yasskin-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.
2009-01-31more flags which only work for function blocksBenjamin Peterson-6/+4
2009-01-31add explanatory commentBenjamin Peterson-0/+2
2009-01-17#4077: No need to append \n when calling Py_FatalErrorAmaury Forgeot d'Arc-1/+1
+ fix a declaration to make it match the one in pythonrun.h
2008-12-27#4748 lambda generators shouldn't return valuesBenjamin Peterson-1/+6
2008-12-17Issue #2183: Simplify and optimize bytecode for list comprehensions.Antoine Pitrou-26/+7
2008-11-08check for assignment to __debug__ during AST generationBenjamin Peterson-6/+0
Also, give assignment to None a better error message
2008-06-11Merge in release25-maint r60793:Gregory P. Smith-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.
2008-06-09This reverts r63675 based on the discussion in this thread:Gregory P. Smith-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.
2008-05-26Renamed PyString to PyBytesChristian Heimes-47/+47
2008-03-30Patch #2511: Give the "excepthandler" AST item proper attributes by making ↵Georg Brandl-7/+7
it a Sum.
2008-03-28Fix a reference leak found by Georg, when compiling a class nested in ↵Amaury Forgeot d'Arc-0/+1
another class. Now "regrtest.py -R:: test_compile" is satisfied. Will backport.
2008-03-28Patch #1810 by Thomas Lee, reviewed by myself:Georg Brandl-6/+14
allow compiling Python AST objects into code objects in compile().
2008-03-15Add a warning for code like:Neal Norwitz-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.
2008-03-07Speed up with statements by storing the __exit__ method on the stack instead ↵Nick Coghlan-14/+6
of in a temp variable (bumps the magic number for pyc files)
2008-02-25Fix indentationNeal Norwitz-1/+1
2008-02-23Patch #1759: Backport of PEP 3129 class decoratorsChristian Heimes-2/+11
with some help from Georg
2008-02-07Cast a struct to a void pointer so as to do a type-safe pointer comparisonBrett Cannon-3/+3
(mistmatch found by clang).
2008-02-05Change r60575 broke test_compile:Amaury Forgeot d'Arc-0/+3
there is no need to emit co_lnotab item when both offsets are zeros.
2008-02-04#1750076: Debugger did not step on every iteration of a while statement.Amaury Forgeot d'Arc-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.
2008-01-31Issue #1678380. Fix a bug that identifies 0j and -0j when they appearMark Dickinson-12/+47
in the same code unit. The fix is essentially the same as the fix for a previous bug identifying 0. and -0.
2008-01-28static PyObject* variables should use PyString_InternFromString() instead of ↵Christian Heimes-2/+2
PyObject_FromString() to store a python string in a function level static var.
2008-01-24#1920: when considering a block starting by "while 0", the compiler ↵Amaury Forgeot d'Arc-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.
2007-12-20Add commentsRaymond Hettinger-3/+3
2007-12-19Bigger range for non-extended opargs.Raymond Hettinger-1/+1
2007-12-19Zap a duplicate lineRaymond Hettinger-1/+0
2007-12-18Give meaning to the oparg for BUILD_MAP: estimated size of the dictionary.Raymond Hettinger-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.
2007-12-18Speed-up dictionary constructor by about 10%.Raymond Hettinger-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
2007-09-19Fix #1169: remove docstrings in functions for -OO.Georg Brandl-1/+1
2007-08-25Revert compile.c changes that shouldn't have been included in previous checkinNick Coghlan-7/+2
2007-08-25Revert misguided attempt at fixing incompatibility between -m and -i ↵Nick Coghlan-2/+7
switches (better fix coming soon)
2007-08-22Fix compile.c so that it records 0.0 and -0.0 as separate constants in a codeAlex Martelli-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.
2007-06-01Bug #1722484: remove docstrings again when running with -OO.Georg Brandl-1/+2
2007-02-27tabifyJeremy Hylton-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.
2007-02-27Fix long-standing bug in name mangling for package importsJeremy Hylton-2/+12
Reported by Mike Verdone.
2006-10-29Update comments, remove commented out code.Neal Norwitz-87/+31
Move assembler structure next to assembler code to make it easier to move it to a separate file.
2006-10-29Clean up a leftover from old listcomp generation code.Georg Brandl-7/+1
2006-10-28Fix bug #1565514, SystemError not raised on too many nested blocks.Neal Norwitz-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.
2006-10-04Fix for SF bug 1569998: break permitted inside try.Jeremy Hylton-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.