summaryrefslogtreecommitdiffstats
path: root/Lib/opcode.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-44525: Copy free variables in bytecode to allow calls to inner functions ↵Mark Shannon2021-11-231-0/+1
| | | | | | | | | | | to be specialized (GH-29595) * Make internal APIs that take PyFrameConstructor take a PyFunctionObject instead. * Add reference to function to frame, borrow references to builtins and globals. * Add COPY_FREE_VARS instruction to allow specialization of calls to inner functions.
* bpo-45609: Specialize STORE_SUBSCR (GH-29242)Dennis Sweeney2021-11-191-0/+3
| | | | | * Specialize STORE_SUBSCR for list[int], and dict[object] * Adds _PyDict_SetItem_Take2 which consumes references to the key and values.
* bpo-45829: Specialize BINARY_SUBSCR for __getitem__ implemented in Python. ↵Mark Shannon2021-11-181-0/+1
| | | | (GH-29592)
* bpo-45510: Specialize BINARY_SUBTRACT (GH-29523)Dong-hee Na2021-11-181-0/+2
|
* bpo-45636: Merge all numeric operators (GH-29482)Brandt Bucher2021-11-111-36/+39
|
* bpo-44511: Improve the bytecode for class and mapping patterns (GH-26922)Brandt Bucher2021-10-271-2/+2
| | | | | | | * Refactor mapping patterns and speed up class patterns. * Simplify MATCH_KEYS and MATCH_CLASS. * Add COPY opcode.
* bpo-44525: Specialize simple Python calls. (GH-29033)Mark Shannon2021-10-201-0/+1
|
* bpo-44525: Specialize ``CALL_FUNCTION`` for C function calls (GH-26934)Ken Jin2021-10-191-0/+5
|
* bpo-45367: Specialize BINARY_MULTIPLY (GH-28727)Dennis Sweeney2021-10-141-0/+3
|
* bpo-45340: Don't create object dictionaries unless actually needed (GH-28802)Mark Shannon2021-10-131-2/+3
| | | | | | | | | | | | | | * Never change types' cached keys. It could invalidate inline attribute objects. * Lazily create object dictionaries. * Update specialization of LOAD/STORE_ATTR. * Don't update shared keys version for deletion of value. * Update gdb support to handle instance values. * Rename SPLIT_KEYS opcodes to INSTANCE_VALUE.
* bpo-44945: Specialize BINARY_ADD (GH-27967)Mark Shannon2021-08-271-0/+5
|
* bpo-44889: Specialize LOAD_METHOD with PEP 659 adaptive interpreter (GH-27722)Ken Jin2021-08-171-0/+4
| | | | | | | | Adds four new instructions: * LOAD_METHOD_ADAPTIVE * LOAD_METHOD_CACHED * LOAD_METHOD_MODULE * LOAD_METHOD_CLASS
* bpo-44900: Add five superinstructions. (GH-27741)Mark Shannon2021-08-161-1/+6
| | | | | | | | * LOAD_FAST LOAD_FAST * STORE_FAST LOAD_FAST * LOAD_FAST LOAD_CONST * LOAD_CONST LOAD_FAST * STORE_FAST STORE_FAST
* bpo-44826: Specialize STORE_ATTR (GH-27590)Mark Shannon2021-08-091-0/+4
| | | | | | | * Generalize cache names for LOAD_ATTR to allow store and delete specializations. * Factor out specialization of attribute dictionary access. * Specialize STORE_ATTR.
* bpo-44725 : expose specialization stats in python (GH-27192)Irit Katriel2021-07-291-0/+10
|
* bpo-26280: Port BINARY_SUBSCR to PEP 659 adaptive interpreter (GH-27043)Irit Katriel2021-07-151-0/+4
|
* bpo-44338: Port LOAD_GLOBAL to PEP 659 adaptive interpreter (GH-26638)Mark Shannon2021-06-141-0/+3
| | | | | | | | | | * Add specializations of LOAD_GLOBAL. * Add more stats. * Remove old opcache; it is no longer used. * Add NEWS
* bpo-44337: Port LOAD_ATTR to PEP 659 adaptive interpreter (GH-26595)Mark Shannon2021-06-101-0/+9
| | | | | | | | | | | | | | * Specialize LOAD_ATTR with LOAD_ATTR_SLOT and LOAD_ATTR_SPLIT_KEYS * Move dict-common.h to internal/pycore_dict.h * Add LOAD_ATTR_WITH_HINT specialized opcode. * Quicken in function if loopy * Specialize LOAD_ATTR for module attributes. * Add specialization stats
* bpo-43693: Un-revert commit f3fa63e. (#26609)Eric Snow2021-06-081-4/+6
| | | | | | | | | This was reverted in GH-26596 (commit 6d518bb) due to some bad memory accesses. * Add the MAKE_CELL opcode. (gh-26396) The memory accesses have been fixed. https://bugs.python.org/issue43693
* Revert "bpo-43693: Add the MAKE_CELL opcode and interleave fast locals ↵Pablo Galindo2021-06-081-6/+4
| | | | | offsets. (gh-26396)" (GH-26597) This reverts commit 631f9938b1604d4f893417ec339b9e0fa9196fb1.
* bpo-43693: Add the MAKE_CELL opcode and interleave fast locals offsets. ↵Eric Snow2021-06-071-4/+6
| | | | | | | (gh-26396) This moves logic out of the frame initialization code and into the compiler and eval loop. Doing so simplifies the runtime code and allows us to optimize it better. https://bugs.python.org/issue43693
* bpo-26110: Add ``CALL_METHOD_KW`` opcode to speedup method calls with ↵Ken Jin2021-05-151-0/+1
| | | | | | | | | keywords (GH-26014) * Add CALL_METHOD_KW * Make CALL_METHOD branchless too since it shares the same code * Place parentheses in STACK_SHRINK
* bpo-40222: "Zero cost" exception handling (GH-25729)Mark Shannon2021-05-071-4/+5
| | | | | | | | "Zero cost" exception handling. * Uses a lookup table to determine how to handle exceptions. * Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements. * Reduces the size of the frame object by about 60%.
* bpo-43754: Eliminate bindings for partial pattern matches (GH-25229)Brandt Bucher2021-05-021-1/+1
|
* bpo-43683: Handle generator entry in bytecode (GH-25138)Mark Shannon2021-04-061-0/+1
| | | | | | * Handle check for sending None to starting generator and coroutine into bytecode. * Document new bytecode and make it fail gracefully if mis-compiled.
* bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)Brandt Bucher2021-02-261-12/+10
| | | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Talin <viridia@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-42246: Make sure that `f_lasti`, and thus `f_lineno`, is set correctly ↵Mark Shannon2020-12-171-1/+1
| | | | | | | | | after raising or reraising an exception (GH-23803) * Ensure that f_lasti is set correctly after an exception is raised to conform to PEP 626. * Update importlib * Add NEWS.
* bpo-39320: Handle unpacking of **values in compiler (GH-18141)Mark Shannon2020-01-271-3/+2
| | | | | | | | | | | | | * Add DICT_UPDATE and DICT_MERGE bytecodes. Use them for ** unpacking. * Remove BUILD_MAP_UNPACK and BUILD_MAP_UNPACK_WITH_CALL, as they are now unused. * Update magic number for ** unpacking opcodes. * Update dis.rst to incorporate new bytecodes. * Add blurb entry.
* bpo-39320: Handle unpacking of *values in compiler (GH-17984)Mark Shannon2020-01-231-4/+4
| | | | | | | | * Add three new bytecodes: LIST_TO_TUPLE, LIST_EXTEND, SET_UPDATE. Use them to implement star unpacking expressions. * Remove four bytecodes BUILD_LIST_UNPACK, BUILD_TUPLE_UNPACK, BUILD_SET_UNPACK and BUILD_TUPLE_UNPACK_WITH_CALL opcodes as they are now unused. * Update magic number and dis.rst for new bytecodes.
* bpo-39156: Break up COMPARE_OP into four logically distinct opcodes. (GH-17754)Mark Shannon2020-01-141-2/+5
| | | | | | | | Break up COMPARE_OP into four logically distinct opcodes: * COMPARE_OP for rich comparisons * IS_OP for 'is' and 'is not' tests * CONTAINS_OP for 'in' and 'is not' tests * JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
* Produce cleaner bytecode for 'with' and 'async with' by generating separate ↵Mark Shannon2019-11-211-6/+5
| | | | | | code for normal and exceptional paths. (#6641) Remove BEGIN_FINALLY, END_FINALLY, CALL_FINALLY and POP_FINALLY bytecodes. Implement finally blocks by code duplication. Reimplement frame.lineno setter using line numbers rather than bytecode offsets.
* bpo-34880: Add the LOAD_ASSERTION_ERROR opcode. (GH-15073)Zackery Spytz2019-08-251-1/+1
| | | | Fix assert statement misbehavior if AssertionError is shadowed.
* bpo-33041: Rework compiling an "async for" loop. (#6142)Serhiy Storchaka2018-03-231-1/+1
| | | | | | | | * Added new opcode END_ASYNC_FOR. * Setting global StopAsyncIteration no longer breaks "async for" loops. * Jumping into an "async for" loop is now disabled. * Jumping out of an "async for" loop no longer corrupts the stack. * Simplify the compiler.
* bpo-17611. Move unwinding of stack for "pseudo exceptions" from interpreter ↵Serhiy Storchaka2018-02-221-6/+5
| | | | | | | | | to compiler. (GH-5006) Co-authored-by: Mark Shannon <mark@hotpy.org> Co-authored-by: Antoine Pitrou <antoine@python.org>
* bpo-32746: Fix multiple typos (GH-5144)Leo Arias2018-02-041-1/+1
| | | Fix typos found by codespell in docs, docstrings, and comments.
* bpo-32550. Remove the STORE_ANNOTATION bytecode. (GH-5181)Mark Shannon2018-01-301-1/+0
|
* Issue #26110: Add LOAD_METHOD/CALL_METHOD opcodes.Yury Selivanov2016-12-141-0/+3
| | | | | | | Special thanks to INADA Naoki for pushing the patch through the last mile, Serhiy Storchaka for reviewing the code, and to Victor Stinner for suggesting the idea (originally implemented in the PyPy project).
* Issue #28257: Improved error message when pass a non-iterable asSerhiy Storchaka2016-10-021-2/+3
| | | | a var-positional argument. Added opcode BUILD_TUPLE_UNPACK_WITH_CALL.
* Rework CALL_FUNCTION* opcodesVictor Stinner2016-09-091-9/+4
| | | | | | | | | | | | | | | | | | | Issue #27213: Rework CALL_FUNCTION* opcodes to produce shorter and more efficient bytecode: * CALL_FUNCTION now only accepts position arguments * CALL_FUNCTION_KW accepts position arguments and keyword arguments, but keys of keyword arguments are packed into a constant tuple. * CALL_FUNCTION_EX is the most generic, it expects a tuple and a dict for positional and keyword arguments. CALL_FUNCTION_VAR and CALL_FUNCTION_VAR_KW opcodes have been removed. 2 tests of test_traceback are currently broken: skip test, the issue #28050 was created to track the issue. Patch by Demur Rumed, design by Serhiy Storchaka, reviewed by Serhiy Storchaka and Victor Stinner.
* Issue #27985: Implement PEP 526 -- Syntax for Variable Annotations.Yury Selivanov2016-09-091-1/+2
| | | | Patch by Ivan Levkivskyi.
* Issue #27078: Added BUILD_STRING opcode. Optimized f-strings evaluation.Serhiy Storchaka2016-09-061-0/+1
|
* Issue #27095: Simplified MAKE_FUNCTION and removed MAKE_CLOSURE opcodes.Serhiy Storchaka2016-06-121-2/+1
| | | | Patch by Demur Rumed.
* Issue #27140: Added BUILD_CONST_KEY_MAP opcode.Serhiy Storchaka2016-06-111-0/+1
|
* Issue #26647: Cleanup opcodeVictor Stinner2016-04-121-3/+1
| | | | Simplify code to build opcode.opname. Patch written by Demur Rumed.
* Issue 25483: Add an opcode to make f-string formatting more robust.Eric V. Smith2015-11-031-0/+2
|
* Issue #24400: Introduce a distinct type for 'async def' coroutines.Yury Selivanov2015-06-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary of changes: 1. Coroutines now have a distinct, separate from generators type at the C level: PyGen_Type, and a new typedef PyCoroObject. PyCoroObject shares the initial segment of struct layout with PyGenObject, making it possible to reuse existing generators machinery. The new type is exposed as 'types.CoroutineType'. As a consequence of having a new type, CO_GENERATOR flag is no longer applied to coroutines. 2. Having a separate type for coroutines made it possible to add an __await__ method to the type. Although it is not used by the interpreter (see details on that below), it makes coroutines naturally (without using __instancecheck__) conform to collections.abc.Coroutine and collections.abc.Awaitable ABCs. [The __instancecheck__ is still used for generator-based coroutines, as we don't want to add __await__ for generators.] 3. Add new opcode: GET_YIELD_FROM_ITER. The opcode is needed to allow passing native coroutines to the YIELD_FROM opcode. Before this change, 'yield from o' expression was compiled to: (o) GET_ITER LOAD_CONST YIELD_FROM Now, we use GET_YIELD_FROM_ITER instead of GET_ITER. The reason for adding a new opcode is that GET_ITER is used in some contexts (such as 'for .. in' loops) where passing a coroutine object is invalid. 4. Add two new introspection functions to the inspec module: getcoroutinestate(c) and getcoroutinelocals(c). 5. inspect.iscoroutine(o) is updated to test if 'o' is a native coroutine object. Before this commit it used abc.Coroutine, and it was requested to update inspect.isgenerator(o) to use abc.Generator; it was decided, however, that inspect functions should really be tailored for checking for native types. 6. sys.set_coroutine_wrapper(w) API is updated to work with only native coroutines. Since types.coroutine decorator supports any type of callables now, it would be confusing that it does not work for all types of coroutines. 7. Exceptions logic in generators C implementation was updated to raise clearer messages for coroutines: Before: TypeError("generator raised StopIteration") After: TypeError("coroutine raised StopIteration")
* remove STORE_MAP, since it's unusedBenjamin Peterson2015-05-281-1/+0
|
* PEP 0492 -- Coroutines with async and await syntax. Issue #24017.Yury Selivanov2015-05-121-1/+9
|
* PEP 448: additional unpacking generalizations (closes #2292)Benjamin Peterson2015-05-061-0/+6
| | | | Patch by Neil Girdhar.
* PEP 465: a dedicated infix operator for matrix multiplication (closes #21176)Benjamin Peterson2014-04-101-0/+3
|