summaryrefslogtreecommitdiff
path: root/Python/ceval.c
Commit message (Collapse)AuthorAgeFilesLines
* Patch #957398: Add public API for Generator Object/Type.Martin v. Löwis2004-06-011-138/+8
|
* Some (but not all) of the why code bitfield tests ran faster asRaymond Hettinger2004-04-111-3/+4
| | | | separate equality tests. Now, all are set to their best timing.
* Revert 2.393, elimination of pre-decrementing, whichRaymond Hettinger2004-04-101-17/+13
| | | | did not stand-up to additional timings.
* Use continue instead of break whereever possible.Raymond Hettinger2004-04-071-2/+8
|
* * Improve readability and remove data dependencies by convertingRaymond Hettinger2004-04-071-14/+18
| | | | | | | | pre-increment forms to post-increment forms. Post-incrementing also eliminates the need for negative array indices for oparg fetches. * In exception handling code, check for class based exceptions before the older string based exceptions.
* Small code improvements for readability, code size, and/or speed.Raymond Hettinger2004-04-071-58/+54
| | | | | | | | | | | | | | | | | | | | | | | BINARY_SUBSCR: * invert test for normal case fall through * eliminate err handling code by jumping to slow_case LOAD_LOCALS: * invert test for normal case fall through * continue instead of break for the non-error case STORE_NAME and DELETE_NAME: * invert test for normal case fall through LOAD_NAME: * continue instead of break for the non-error case DELETE_FAST: * invert test for normal case fall through LOAD_DEREF: * invert test for normal case fall through * continue instead of break for the non-error case
* Simplify previous checkin (bitfields for WHY codes).Raymond Hettinger2004-04-061-12/+14
| | | | Restores the self-documenting enum declaration.
* Coded WHY flags as bitfields (taking inspiration from tp_flags).Raymond Hettinger2004-04-061-20/+16
| | | | | This allows multiple flags to be tested in a single compare which eliminates unnecessary compares and saves a few bytes.
* Since the fast_yield branch target was introduced, it appears that mostTim Peters2004-04-051-41/+41
| | | | | | | tests of "why" against WHY_YIELD became useless. This patch removes them, but assert()s that why != WHY_YIELD everywhere such a test was removed. The test suite ran fine under a debug build (i.e., the asserts never triggered).
* Changed random calls to PyThreadState_Get() to use the macroNicholas Bastin2004-03-241-5/+5
|
* Enable the profiling of C functions (builtins and extensions)Nicholas Bastin2004-03-241-3/+48
|
* Fix SF bug #765624.Armin Rigo2004-03-221-5/+12
|
* Cancelled checkin, sorry.Armin Rigo2004-03-201-10/+6
|
* A 2% speed improvement with gcc on low-endian machines. My guess is that thisArmin Rigo2004-03-201-6/+10
| | | | | new pattern for NEXTARG() is detected and optimized as a single (*short) loading.
* LIST_APPEND is predicably followed by JUMP_ABSOLUTE.Raymond Hettinger2004-03-121-1/+5
| | | | Reduces loop overhead by an additional 10%.
* Move the code for BREAK and CONTINUE_LOOP to be near FOR_ITER.Raymond Hettinger2004-03-121-9/+9
| | | | | Makes it more likely that all loop operations are in the cache at the same time.
* Speedup for-loops by inlining PyIter_Next(). Saves duplicate testsRaymond Hettinger2004-03-121-8/+10
| | | | | and a function call resulting in a 15% reduction of total loop overhead (as measured by timeit.Timer('pass')).
* Refactor and optimize code for UNPACK_SEQUENCE.Raymond Hettinger2004-03-081-27/+13
| | | | | | | | | | * Defer error handling for wrong number of arguments to the unpack_iterable() function. Cuts the code size almost in half. * Replace function calls to PyList_Size() and PyTuple_Size() with their smaller and faster macro counterparts. * Move the constant structure references outside of the inner loops.
* SF patch #910929: Optimize list comprehensionsRaymond Hettinger2004-03-071-0/+9
| | | | | 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.
* Add pystack definition to Misc/gdbinit with some explanation of its behaviorSkip Montanaro2004-03-011-0/+4
| | | | | and add flag comments to ceval.c and main.c alerting people to the coupling between pystack and the layout of those files.
* This is my patch #876198 plus a NEWS entry and a header frob.Michael W. Hudson2004-02-121-1/+1
| | | | | Remove the ability to use (from C) arbitrary objects supporting the read buffer interface as the co_code member of code objects.
* remove support for missing ANSI C header files (limits.h, stddef.h, etc).Skip Montanaro2004-02-101-11/+0
|
* SF patch #884022: dynamic execution profiling vs opcode predictionRaymond Hettinger2004-02-081-0/+9
| | | | | | | | | (Contributed by Andrew I MacIntyre.) disables opcode prediction when dynamic execution profiling is in effect, so the profiling counters at the top of the main interpreter loop in eval_frame() are updated for each opcode.
* SF patch #864059: optimize eval_frameRaymond Hettinger2004-02-061-5/+6
| | | | | | Simplified version of Neal Norwitz's patch which adds gotos for opcodes that set "why". This skips a number of tests where the outcome of the tests are known in advance.
* Getting rid of all the code inside #ifdef macintosh too.Jack Jansen2003-11-201-5/+1
|
* Make undetected error on stack unwind a fatal error.Jeremy Hylton2003-11-051-4/+4
|
* Deleting cyclic object comparison.Armin Rigo2003-10-281-20/+36
| | | | | SF patch 825639 http://mail.python.org/pipermail/python-dev/2003-October/039445.html
* oh dear. Wrong manipulation. Committed a version of ceval.c from myArmin Rigo2003-10-251-28/+20
| | | | | | no-cyclic-comparison patch at the same time as errors.c. Reverting ceval.c to the previous revision.
* Made function declaration a proper C prototypeArmin Rigo2003-10-251-20/+28
|
* Simplify and speedup uses of Py_BuildValue():Raymond Hettinger2003-10-121-3/+3
| | | | | | * 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 #762455, segfault when sys.stdout is changed in getattrNeal Norwitz2003-06-291-0/+6
| | | | Will backport.
* Add PyThreadState_SetAsyncExc(long, PyObject *).Guido van Rossum2003-06-281-1/+17
| | | | | | | | | A new API (only accessible from C) to interrupt a thread by sending it an exception. This is not always effective, but might help some people. Requested by Just van Rossum and Alex Martelli. It is intentional that you have to write your own C extension to call it from Python. Docs will have to wait.
* Use fast_next_opcode shortcut for forward jump opcodes (it's safe andNeil Schemenauer2003-06-011-5/+5
| | | | gives a small speedup).
* SF bug #733667: kwargs handled incorrectlyRaymond Hettinger2003-05-311-1/+1
| | | | | The fast_function() inlining optimization only applies when there are zero keyword arguments.
* Don't use fast_next_opcode for JUMP_* opcodes. This fixes the problemNeil Schemenauer2003-05-301-6/+6
| | | | reported by Kurt B. Kaiser.
* Armin Rigo's fix & test forMichael W. Hudson2003-04-291-9/+10
| | | | | | [ 729622 ] line tracing hook errors with massaging from me to integrate test into test suite.
* Revert the previous enhancement to the bytecode optimizer.Raymond Hettinger2003-04-241-3/+0
| | | | The additional code complexity and new NOP opcode were not worth it.
* Improved the bytecode optimizer.Raymond Hettinger2003-04-221-0/+3
| | | | | | | | | | | | | | * 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.
* New PyGILState_ API - implements pep 311, from patch 684256.Mark Hammond2003-04-191-0/+2
|
* - New function sys.call_tracing() allows pdb to debug codeGuido van Rossum2003-04-091-0/+18
| | | | | | recursively. - pdb has a new command, "debug", which lets you step through arbitrary code from the debugger's (pdb) prompt.
* Eliminate data dependency in predict macro.Raymond Hettinger2003-03-161-2/+8
| | | | | | | | Added two predictions: GET_ITER --> FOR_ITER FOR_ITER --> STORE_FAST or UNPACK_SEQUENCE Improves timings on pybench and timeit.py. Pystone results are neutral.
* Fix comment and whitespace.Raymond Hettinger2003-03-161-3/+4
|
* Introduced macros for a simple opcode prediction protocol.Raymond Hettinger2003-03-161-6/+35
| | | | | | | | | | | | | | | | | | | Applied to common cases: COMPARE_OP is often followed by a JUMP_IF. JUMP_IF is usually followed by POP_TOP. Shows improved timings on PyStone, PyBench, and specific tests using timeit.py: python timeit.py -s "x=1" "if x==1: pass" python timeit.py -s "x=1" "if x==2: pass" python timeit.py -s "x=1" "if x: pass" python timeit.py -s "x=100" "while x!=1: x-=1" Potential future candidates: GET_ITER predicts FOR_ITER FOR_ITER predicts STORE_FAST or UNPACK_SEQUENCE Also, applied missing goto fast_next_opcode to DUP_TOPX.
* SF patch #701907: More use of fast_next_opcodeRaymond Hettinger2003-03-141-11/+11
| | | | | | | | My previous patches should have used fast_next_opcode in a few places instead of continue. Also, applied one PyInt_AS_LONG macro in a place where the type had already been checked.
* Added implementation notes for [re]set_exc_info().Guido van Rossum2003-03-011-0/+61
|
* In the process of adding all the extended slice support I attempted toMichael W. Hudson2003-02-271-4/+4
| | | | | | | change _PyEval_SliceIndex to round massively negative longs up to -INT_MAX, instead of 0 but botched it. Get it right. Thx to Armin for the report.
* Micro-optimizations.Raymond Hettinger2003-02-261-4/+18
| | | | | * List/Tuple checkexact is faster for the common case. * Testing for Py_True and Py_False can be inlined for faster looping.
* - PyEval_GetFrame() is now declared to return a PyFrameObject *Guido van Rossum2003-02-191-7/+7
| | | | instead of a plain PyObject *. (SF patch #686601 by Ben Laurie.)
* patch #683515: "Add unicode support to compile(), eval() and exec"Just van Rossum2003-02-101-2/+13
| | | | Incorporated nnorwitz's comment re. Py__USING_UNICODE.
* Small function call optimization and special build option for call stats.Jeremy Hylton2003-02-051-12/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | -DCALL_PROFILE: Count the number of function calls executed. When this symbol is defined, the ceval mainloop and helper functions count the number of function calls made. It keeps detailed statistics about what kind of object was called and whether the call hit any of the special fast paths in the code. Optimization: When we take the fast_function() path, which seems to be taken for most function calls, and there is minimal frame setup to do, avoid call PyEval_EvalCodeEx(). The eval code ex function does a lot of work to handle keywords args and star args, free variables, generators, etc. The inlined version simply allocates the frame and copies the arguments values into the frame. The optimization gets a little help from compile.c which adds a CO_NOFREE flag to code objects that don't have free variables or cell variables. This change allows fast_function() to get into the fast path with fewer tests. I measure a couple of percent speedup in pystone with this change, but there's surely more that can be done.