summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* Re-running python with/without the -Qnew flag uses incorrectly optimizedArmin Rigo2005-01-071-6/+3
| | | | | bytecodes from the previously saved .pyc files. Fixed by disabling the static optimization of BINARY_DIVIDE between two constants.
* Teach the peephole optimizer to fold simple constant expressions.Raymond Hettinger2005-01-021-1/+118
|
* SF patch 1025636: Check for NULL returns in compile.c:com_import_stmtJeremy Hylton2004-11-071-4/+14
| | | | There is no test for this change, because there is no way to provoke memory errors on demand. Test suite passes, though.
* Maintain peepholer's cumlc invariant by updating the running totalRaymond Hettinger2004-11-021-0/+4
| | | | | | everytime a LOAD_CONSTANT is encountered, created, or overwritten. Added two tests to cover cases affected by the patch.
* Simplify and future proof NOP counting in the peepholer.Raymond Hettinger2004-11-011-13/+6
| | | | No longer assumes that the input is NOP free.
* Fixed a comment and added another one.Armin Rigo2004-10-301-1/+4
|
* Adopt some peepholer suggestions from Armin Rigo:Raymond Hettinger2004-10-301-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.
* SF bug #1053819: Segfault in tuple_of_constantsRaymond Hettinger2004-10-261-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.
* SF bug #1048870: call arg of lambda not updatingRaymond Hettinger2004-10-241-0/+2
|
* Improve error message for augmented assignments to genexps or listcomps.Raymond Hettinger2004-09-291-2/+2
| | | | | Rather than introduce new logic, took the approach of making the message itself more general.
* Fix two erroneous error messages.Raymond Hettinger2004-09-291-2/+2
|
* Replaced a test with an assertion.Raymond Hettinger2004-09-281-3/+1
| | | | (Suggested by Michael Hudson.)
* SF patch #1031667: Fold tuples of constants into a single constantRaymond Hettinger2004-09-221-11/+91
| | | | | | | | Example: >>> import dis >>> dis.dis(compile('1,2,3', '', 'eval')) 0 0 LOAD_CONST 3 ((1, 2, 3)) 3 RETURN_VALUE
* SF patch #1007189, multi-line imports, for instance:Anthony Baxter2004-08-311-31/+47
| | | | | "from blah import (foo, bar baz, bongo)"
* Bypass peepholing of code with lineno tables having intervals >= 255.Raymond Hettinger2004-08-251-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.
* Fix typo in comment and add clarification.Raymond Hettinger2004-08-251-1/+2
|
* Simplify chains of conditional jumps.Raymond Hettinger2004-08-251-2/+25
| | | | (Suggested by Neal Norwitz.)
* Incorporate review comments courtesy of Neal Norwitz:Raymond Hettinger2004-08-241-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.
* SF Patch #1013667: Cleanup Peepholer OutputRaymond Hettinger2004-08-231-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.
* Move the bytecode optimizer upstream so that its results are saved in pycRaymond Hettinger2004-08-181-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.)
* This is Mark Russell's patch:Michael W. Hudson2004-08-171-22/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ 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)
* Correct the order of application for decorators. Meant to be bottom-up and notBrett Cannon2004-08-151-1/+4
| | | | top-down. Now matches the PEP.
* Fix incorrect comment for (struct compiling)->c_cellvarsBrett Cannon2004-08-151-1/+1
|
* code_new(): Wouldn't compile on Windows, because of gcc'ism.Tim Peters2004-08-121-1/+1
|
* Fix bugMichael W. Hudson2004-08-121-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.
* SF bug #1004088: big code objects (>64K) may be optimized incorrectlyRaymond Hettinger2004-08-061-0/+5
| | | | Will backport.
* Revert 2.312; turns out interning the file name did do some good (reducingMichael W. Hudson2004-08-041-1/+1
| | | | .pyc size) after all.
* Don't intern the filename of a file being compiled.Michael W. Hudson2004-08-031-1/+1
| | | | | Hard to believe it ever helped anything, and it hurts finding reference leaks.
* fix for @decorators under a debug build.Anthony Baxter2004-08-021-0/+1
|
* PEP-0318, @decorator-style. In Guido's words:Anthony Baxter2004-08-021-15/+112
| | | | | "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728.
* Upgrade None assignment SyntaxWarning to a SyntaxError.Raymond Hettinger2004-07-171-7/+6
|
* optimize_code(): Repaired gross error in new special-casing for None.Tim Peters2004-07-171-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.
* Treat None as a constant.Raymond Hettinger2004-07-161-4/+20
|
* Remove unused macros in .c filesNeal Norwitz2004-07-081-5/+0
|
* Move NOP to end of code transformation.Raymond Hettinger2004-06-241-3/+7
|
* Install two code generation optimizations that depend on NOP.Raymond Hettinger2004-06-211-3/+30
| | | | Reduces the cost of "not" to almost zero.
* Patch #774665: Make Python LC_NUMERIC agnostic.Martin v. Löwis2004-06-081-2/+2
|
* SF patch #872326: Generator expression implementationRaymond Hettinger2004-05-191-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.
* Fix for line events in the case:Armin Rigo2004-03-221-1/+31
| | | | | | | | def f(a): if a: print 5 else: pass
* Improve byte coding for multiple assignments.Raymond Hettinger2004-03-211-3/+74
| | | | Gives 30% speedup on "a,b=1,2" and 25% on "a,b,c=1,2,3".
* SF patch #910929: Optimize list comprehensionsRaymond Hettinger2004-03-071-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.
* - Removed FutureWarnings related to hex/oct literals and conversionsGuido van Rossum2003-11-291-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.
* Patch #792869: Clarify error message for parameters declared global,Martin v. Löwis2003-10-181-4/+3
| | | | rename LOCAL_GLOBAL to PARAM_GLOBAL.
* Simplify and speedup uses of Py_BuildValue():Raymond Hettinger2003-10-121-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)
* Fix SF bug [ 808594 ] leak on lambda with duplicate arguments error.Jeremy Hylton2003-09-221-15/+16
| | | | | | | Refactor code so that one helper routine sets error location and increments st_errors. Bug fix candidate.
* Improve the leak fix so that PyTuple_New is only called when needed.Raymond Hettinger2003-09-161-9/+11
|
* Fix leak discovered in test_new by Michael Hudson.Raymond Hettinger2003-09-151-17/+14
| | | | Will backport to 2.3.1
* Fix for SF bug [ 784075 ] Fatal Python error: unknown scopeJeremy Hylton2003-08-281-4/+12
| | | | | Make sure the inner function is not compiled when there is a syntax error in the default arguments.
* SF patch 763201: handling of SyntaxErrors in symbol table buildJeremy Hylton2003-07-151-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.
* Removed bytecode transformation for sequence packing/unpacking.Raymond Hettinger2003-06-201-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