summaryrefslogtreecommitdiff
path: root/Python/compile.c
AgeCommit message (Collapse)AuthorLines
2004-11-02Maintain peepholer's cumlc invariant by updating the running totalRaymond Hettinger-0/+4
everytime a LOAD_CONSTANT is encountered, created, or overwritten. Added two tests to cover cases affected by the patch.
2004-11-01Simplify and future proof NOP counting in the peepholer.Raymond Hettinger-13/+6
No longer assumes that the input is NOP free.
2004-10-30Fixed a comment and added another one.Armin Rigo-1/+4
2004-10-30Adopt some peepholer suggestions from Armin Rigo:Raymond Hettinger-15/+20
* Use simpler, faster two pass algorithm for markblocks(). * Free the blocks variable if not NULL and exiting without change. * Verify that the rest of the compiler has not set an exception. * Make the test for tuple of constants less restrictive. * Embellish the comment for chained conditional jumps.
2004-10-26SF bug #1053819: Segfault in tuple_of_constantsRaymond Hettinger-1/+9
Peepholer could be fooled into misidentifying a tuple_of_constants. Added code to count consecutive occurrences of LOAD_CONST. Use the count to weed out the misidentified cases. Added a unittest.
2004-10-24SF bug #1048870: call arg of lambda not updatingRaymond Hettinger-0/+2
2004-09-29Improve error message for augmented assignments to genexps or listcomps.Raymond Hettinger-2/+2
Rather than introduce new logic, took the approach of making the message itself more general.
2004-09-29Fix two erroneous error messages.Raymond Hettinger-2/+2
2004-09-28Replaced a test with an assertion.Raymond Hettinger-3/+1
(Suggested by Michael Hudson.)
2004-09-22SF patch #1031667: Fold tuples of constants into a single constantRaymond Hettinger-11/+91
Example: >>> import dis >>> dis.dis(compile('1,2,3', '', 'eval')) 0 0 LOAD_CONST 3 ((1, 2, 3)) 3 RETURN_VALUE
2004-08-31SF patch #1007189, multi-line imports, for instance:Anthony Baxter-31/+47
"from blah import (foo, bar baz, bongo)"
2004-08-25Bypass peepholing of code with lineno tables having intervals >= 255.Raymond Hettinger-4/+8
Allows the lineno fixup code to remain simple and not have to deal with multibyte codings. * Add an assertion to that effect. * Remove the XXX comment on the subject.
2004-08-25Fix typo in comment and add clarification.Raymond Hettinger-1/+2
2004-08-25Simplify chains of conditional jumps.Raymond Hettinger-2/+25
(Suggested by Neal Norwitz.)
2004-08-24Incorporate review comments courtesy of Neal Norwitz:Raymond Hettinger-6/+8
* Perform the code length check earlier. * Eliminate the extra PyMem_Free() upon hitting an EXTENDED_ARG. * Assert that the NOP count used in jump retargeting matches the NOPs eliminated in the final step. * Add an XXX note to indicate that more work is being to done to handle linenotab with intervals > 255.
2004-08-23SF Patch #1013667: Cleanup Peepholer OutputRaymond Hettinger-35/+100
* Make a pass to eliminate NOPs. Produce code that is more readable, more compact, and a tiny bit faster. Makes the peepholer more flexible in the scope of allowable transformations. * With Guido's okay, bumped up the magic number so that this patch gets widely exercised before the alpha goes out.
2004-08-18Move the bytecode optimizer upstream so that its results are saved in pycRaymond Hettinger-3/+6
files and not re-optimized upon import. Saves a bit of startup time while still remaining decoupled from the rest of the compiler. As a side benefit, handcoded bytecode is not run through the optimizer when new code objects are created. Hopefully, a handcoder has already created exactly what they want to have run. (Idea suggested by Armin Rigo and Michael Hudson. Initially avoided because of worries about compiler coupling; however, only the nexus point needed to be moved so there won't be a conflict when the AST branch is loaded.)
2004-08-17This is Mark Russell's patch:Michael W. Hudson-21/+19
[ 1009560 ] Fix @decorator evaluation order From the description: Changes in this patch: - Change Grammar/Grammar to require newlines between adjacent decorators. - Fix order of evaluation of decorators in the C (compile.c) and python (Lib/compiler/pycodegen.py) compilers - Add better order of evaluation check to test_decorators.py (test_eval_order) - Update the decorator documentation in the reference manual (improve description of evaluation order and update syntax description) and the comment: Used Brett's evaluation order (see http://mail.python.org/pipermail/python-dev/2004-August/047835.html) (I'm checking this in for Anthony who was having problems getting SF to talk to him)
2004-08-15Correct the order of application for decorators. Meant to be bottom-up and notBrett Cannon-1/+4
top-down. Now matches the PEP.
2004-08-15Fix incorrect comment for (struct compiling)->c_cellvarsBrett Cannon-1/+1
2004-08-12code_new(): Wouldn't compile on Windows, because of gcc'ism.Tim Peters-1/+1
2004-08-12Fix bugMichael W. Hudson-27/+88
[ 1005248 ] new.code() not cleanly checking its arguments using the result of new.code() can still destroy the sun, but merely calling the function shouldn't any more. I also rewrote the existing tests of new.code() to use vastly less un-bogus arguments, and added tests for the previous insane behaviours.
2004-08-06SF bug #1004088: big code objects (>64K) may be optimized incorrectlyRaymond Hettinger-0/+5
Will backport.
2004-08-04Revert 2.312; turns out interning the file name did do some good (reducingMichael W. Hudson-1/+1
.pyc size) after all.
2004-08-03Don't intern the filename of a file being compiled.Michael W. Hudson-1/+1
Hard to believe it ever helped anything, and it hurts finding reference leaks.
2004-08-02fix for @decorators under a debug build.Anthony Baxter-0/+1
2004-08-02PEP-0318, @decorator-style. In Guido's words:Anthony Baxter-15/+112
"@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728.
2004-07-17Upgrade None assignment SyntaxWarning to a SyntaxError.Raymond Hettinger-7/+6
2004-07-17optimize_code(): Repaired gross error in new special-casing for None.Tim Peters-1/+2
The preceding case statement was missing a terminating "break" stmt, so fell into the new code by mistake. This caused uncaught out-of-bounds accesses to the "names" tuple, leading to a variety of insane behaviors.
2004-07-16Treat None as a constant.Raymond Hettinger-4/+20
2004-07-08Remove unused macros in .c filesNeal Norwitz-5/+0
2004-06-24Move NOP to end of code transformation.Raymond Hettinger-3/+7
2004-06-21Install two code generation optimizations that depend on NOP.Raymond Hettinger-3/+30
Reduces the cost of "not" to almost zero.
2004-06-08Patch #774665: Make Python LC_NUMERIC agnostic.Martin v. Löwis-2/+2
2004-05-19SF patch #872326: Generator expression implementationRaymond Hettinger-7/+276
(Code contributed by Jiwon Seo.) The documentation portion of the patch is being re-worked and will be checked-in soon. Likewise, PEP 289 will be updated to reflect Guido's rationale for the design decisions on binding behavior (as described in in his patch comments and in discussions on python-dev). The test file, test_genexps.py, is written in doctest format and is meant to exercise all aspects of the the patch. Further additions are welcome from everyone. Please stress test this new feature as much as possible before the alpha release.
2004-03-22Fix for line events in the case:Armin Rigo-1/+31
def f(a): if a: print 5 else: pass
2004-03-21Improve byte coding for multiple assignments.Raymond Hettinger-3/+74
Gives 30% speedup on "a,b=1,2" and 25% on "a,b,c=1,2,3".
2004-03-07SF patch #910929: Optimize list comprehensionsRaymond Hettinger-3/+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-11-29- Removed FutureWarnings related to hex/oct literals and conversionsGuido van Rossum-13/+1
and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) This addresses most of the remaining semantic changes promised by PEP 237, except for repr() of a long, which still shows the trailing 'L'. The PEP appears to promise warnings for operations that changed semantics compared to Python 2.3, but this is not implemented; we've suffered through enough warnings related to hex/oct literals and I think it's best to be silent now.
2003-10-18Patch #792869: Clarify error message for parameters declared global,Martin v. Löwis-4/+3
rename LOCAL_GLOBAL to PARAM_GLOBAL.
2003-10-12Simplify and speedup uses of Py_BuildValue():Raymond Hettinger-2/+2
* Py_BuildValue("(OOO)",a,b,c) --> PyTuple_Pack(3,a,b,c) * Py_BuildValue("()",a) --> PyTuple_New(0) * Py_BuildValue("O", a) --> Py_INCREF(a)
2003-09-22Fix SF bug [ 808594 ] leak on lambda with duplicate arguments error.Jeremy Hylton-15/+16
Refactor code so that one helper routine sets error location and increments st_errors. Bug fix candidate.
2003-09-16Improve the leak fix so that PyTuple_New is only called when needed.Raymond Hettinger-9/+11
2003-09-15Fix leak discovered in test_new by Michael Hudson.Raymond Hettinger-17/+14
Will backport to 2.3.1
2003-08-28Fix for SF bug [ 784075 ] Fatal Python error: unknown scopeJeremy Hylton-4/+12
Make sure the inner function is not compiled when there is a syntax error in the default arguments.
2003-07-15SF patch 763201: handling of SyntaxErrors in symbol table buildJeremy Hylton-33/+47
Fixes for three related bugs, including errors that caused a script to be ignored without printing an error message. The key problem was a bad interaction between syntax warnings and syntax errors. If an exception was already set when a warning was issued, the warning could clobber the exception. The PyErr_Occurred() check in issue_warning() isn't entirely satisfying (the caller should know whether there was already an error), but a better solution isn't immediately obvious. Bug fix candidate.
2003-06-20Removed bytecode transformation for sequence packing/unpacking.Raymond Hettinger-28/+0
It depended on the previously removed basic block checker to prevent a jump into the middle of the transformed block. Clears SF 757818: tuple assignment -- SystemError: unknown opcode
2003-05-22SF bug #644345, Poor error message for augmented assignNeal Norwitz-2/+2
Update error message. Hopefully this is clearer to some people.
2003-05-22Use macro to get length of list.Jeremy Hylton-8/+2
Remove comment about how code used to work.
2003-05-22Remove comment with very long lines that explained what the code usedJeremy Hylton-3/+3
to do. XXX Please be careful when checking in patches to avoid checking in junk that explains what the patched code used to do.