summaryrefslogtreecommitdiff
path: root/Python/compile.c
AgeCommit message (Collapse)AuthorLines
2021-01-15Mark instructions at end of class scope as artificial. (GH-24222)Mark Shannon-0/+2
2021-01-13Eliminate NOPs in extended blocks. (GH-24209)Mark Shannon-5/+13
2021-01-13bpo-42908: Mark cleanup code at end of try-except and with artificial (#24202)Mark Shannon-31/+104
* Mark bytecodes at end of try-except as artificial. * Make sure that the CFG is consistent throughout optimiization. * Extend line-number propagation logic so that implicit returns after 'try-except' or 'with' have the correct line numbers. * Update importlib
2021-01-05bpo-42823: Fix frame lineno when frame.f_trace is set (GH-24099)Mark Shannon-0/+6
* Add test for frame.f_lineno with/without tracing. * Make sure that frame.f_lineno is correct regardless of whether frame.f_trace is set. * Update importlib * Add NEWS
2021-01-04bpo-42810: Mark jumps at end of if and try statements as artificial. (GH-24091)Mark Shannon-7/+24
* Mark jumps at end of if and try statements as artificial. * Update importlib * Add comment explaining the purpose of ADDOP_JUMP_NOLINE.
2021-01-04Delete the now unused c_do_not_emit_bytecode field. (#24094)Mark Shannon-33/+0
2020-12-23bpo-42246: Don't eliminate jumps to jumps, if it will break PEP 626. (GH-23896)Mark Shannon-51/+84
2020-12-21bpo-42634: Mark reraise after except blocks as artificial. (GH-23877)Mark Shannon-0/+2
* Mark reraise after except blocks as artificial. * Update importlib * Update dis test.
2020-12-17bpo-42246: Make sure that `f_lasti`, and thus `f_lineno`, is set correctly ↵Mark Shannon-4/+4
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.
2020-12-16bpo-42645: Make sure that return/break/continue are only traced once when ↵Mark Shannon-4/+13
exiting via a finally block. (GH-23780) * Make sure that return/break/continue are only traced once when exiting via a finally block. * Add test for return in try-finally. * Update importlib
2020-12-16bpo-42615: Delete redundant jump instructions that only bypass empty blocks ↵Om G-0/+42
(GH-23733) * Delete jump instructions that bypass empty blocks * Add news entry * Explicitly check for unconditional jump opcodes Using the is_jump function results in the inclusion of instructions like returns for which this optimization is not really valid. So, instead explicitly check that the instruction is an unconditional jump. * Handle conditional jumps, delete jumps gracefully * Ensure b_nofallthrough and b_reachable are valid * Add test for redundant jumps * Regenerate importlib.h and edit Misc/ACKS * Fix bad whitespace
2020-12-15bpo-42246: Remove DO_NOT_EMIT_BYTECODE macros, so that while loops and if ↵Mark Shannon-85/+27
statements conform to PEP 626. (GH-23743)
2020-12-14bpo-42635: Mark JUMP_ABSOLUTE at end of 'for' loop as artificial to avoid ↵Mark Shannon-0/+2
spurious line events. (GH-23761)
2020-12-14Don't generate spurious line number in try-except-finally. (#23760)Mark Shannon-0/+2
2020-12-04bpo-42246: Don't forget the entry block when ensuring that all exits have a ↵Mark Shannon-0/+6
line number (GH-23636) Don't forget the entry block when ensuring that all exits have a line number.
2020-12-02bpo-42246: Make sure that line number is correct after a return, as required ↵Mark Shannon-11/+126
by PEP 626 (GH-23495) Make sure that line number is correct after a return, as defined by PEP 626.
2020-11-25bpo-42202: Store func annotations as a tuple (GH-23316)Yurii Karabas-43/+27
Reduce memory footprint and improve performance of loading modules having many func annotations. >>> sys.getsizeof({"a":"int","b":"int","return":"int"}) 232 >>> sys.getsizeof(("a","int","b","int","return","int")) 88 The tuple is converted into dict on the fly when `func.__annotations__` is accessed first. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2020-11-17bpo-42349: Compiler clean up. More yak-shaving for PEP 626. (GH-23267)Mark Shannon-60/+127
Make sure that CFG from compiler front-end is correct. Be a bit more aggressive in the compiler back-end.
2020-11-13bpo-42246: Fix memory leak in compiler (GH-23256)Mark Shannon-7/+13
* Fix potential memory leak in assembler init. * Fix reference leak when encountering error during compilation of function body.
2020-11-12bpo-42246: Eliminate jumps to exit blocks by copying those blocks. (#23251)Mark Shannon-78/+85
* Compiler: eliminate jumps to short exit blocks by copying.
2020-11-12bpo-42246: Partial implementation of PEP 626. (GH-23113)Mark Shannon-99/+103
* Implement new line number table format, as defined in PEP 626.
2020-10-27bpo-42161: Use _PyLong_GetZero() and _PyLong_GetOne() (GH-22995)Victor Stinner-2/+4
Use _PyLong_GetZero() and _PyLong_GetOne() in Objects/ and Python/ directories.
2020-10-26bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and ↵Serhiy Storchaka-3/+3
_PyDict_GetItemId. (GH-22648) These functions are considered not safe because they suppress all internal errors and can return wrong result. PyDict_GetItemString and _PyDict_GetItemId can also silence current exception in rare cases. Remove no longer used _PyDict_GetItemId. Add _PyDict_ContainsId and rename _PyDict_Contains into _PyDict_Contains_KnownHash.
2020-10-06bpo-38605: Make 'from __future__ import annotations' the default (GH-20434)Batuhan Taskaya-12/+2
The hard part was making all the tests pass; there are some subtle issues here, because apparently the future import wasn't tested very thoroughly in previous Python versions. For example, `inspect.signature()` returned type objects normally (except for forward references), but strings with the future import. We changed it to try and return type objects by calling `typing.get_type_hints()`, but fall back on returning strings if that function fails (which it may do if there are future references in the annotations that require passing in a specific namespace to resolve).
2020-09-25bpo-39934: Account for control blocks in 'except' in compiler. (GH-22395)Mark Shannon-8/+11
* Account for control blocks in 'except' in compiler. Fixes #39934.
2020-09-23bpo-40941: Fix fold_tuple_on_constants() compiler warnings (GH-22378)Victor Stinner-4/+2
Add explicit casts to fix compiler warnings in fold_tuple_on_constants(). The limit of constants per code is now INT_MAX, rather than UINT_MAX.
2020-09-16bpo-41746: Add type information to asdl_seq objects (GH-22223)Pablo Galindo-40/+37
* Add new capability to the PEG parser to type variable assignments. For instance: ``` | a[asdl_stmt_seq*]=';'.small_stmt+ [';'] NEWLINE { a } ``` * Add new sequence types from the asdl definition (automatically generated) * Make `asdl_seq` type a generic aliasing pointer type. * Create a new `asdl_generic_seq` for the generic case using `void*`. * The old `asdl_seq_GET`/`ast_seq_SET` macros now are typed. * New `asdl_seq_GET_UNTYPED`/`ast_seq_SET_UNTYPED` macros for dealing with generic sequences. * Changes all possible `asdl_seq` types to use specific versions everywhere.
2020-08-13bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements ↵Pablo Galindo-1/+1
(GH-21850)
2020-08-04bpo-41463: Generate information about jumps from 'opcode.py' rather than ↵Mark Shannon-59/+73
duplicating it in 'compile.c' (GH-21714) Generate information about jumps from 'opcode.py' rather than duplicate it in 'compile.c'
2020-07-30bpo-41323: Perform 'peephole' optimizations directly on the CFG. (GH-21517)Mark Shannon-21/+353
* Move 'peephole' optimizations into compile.c and perform them directly on the CFG.
2020-07-06bpo-41218: Only mark async code with CO_COROUTINE. (#21357)Matthias Bussonnier-4/+6
3.8.3 had a regression where compiling with ast.PyCF_ALLOW_TOP_LEVEL_AWAIT woudl agressively mark things are coroutine even if there were not.
2020-06-28bpo-39151: Simplify DFS in the assembler (GH-17733)Pablo Galindo-33/+18
2020-06-11bpo-40939: Remove the old parser (GH-20768)Pablo Galindo-15/+0
This commit removes the old parser, the deprecated parser module, the old parser compatibility flags and environment variables and all associated support code and documentation.
2020-06-01Make sure that keyword arguments are merged into the arguments dictionary ↵Mark Shannon-0/+3
when dict unpacking and keyword arguments are interleaved. (GH-20553)
2020-04-23bpo-40334: Don't downcast from Py_ssize_t to int (GH-19671)Pablo Galindo-1/+1
2020-04-22bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)Pablo Galindo-0/+67
Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2020-04-13bpo-40268: Add _PyInterpreterState_GetConfig() (GH-19492)Victor Stinner-3/+1
Don't access PyInterpreterState.config member directly anymore, but use new functions: * _PyInterpreterState_GetConfig() * _PyInterpreterState_SetConfig() * _Py_GetConfig()
2020-04-06bpo-40147: Fix a compiler warning on Windows in Python/compile.c (GH-19389)Zackery Spytz-4/+5
Change the type of nkeywords to Py_ssize_t.
2020-04-03bpo-40147: Move the check for duplicate keywords to the compiler (GH-19289)Pablo Galindo-0/+29
2020-03-26bpo-40067: Improve error messages for multiple star expressions in ↵Furkan Önder-1/+1
assignments (GH-19168) Co-Authored-By: Batuhan Taşkaya <isidentical@gmail.com> Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
2020-03-25bpo-39882: Add _Py_FatalErrorFormat() function (GH-19157)Victor Stinner-16/+12
2020-03-24Use calloc-based functions, not malloc. (GH-19152)Andy Lester-8/+4
2020-03-19bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL ↵Batuhan Taşkaya-2/+5
(GH-18968) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-03-18bpo-39220: Do not optimise annotation if 'from __future__ import ↵Pablo Galindo-1/+5
annotations' is used (GH-17866) Do not apply AST-based optimizations if 'from __future__ import annotations' is used in order to prevent information lost in the final version of the annotations.
2020-03-17bpo-39988: Remove ast.AugLoad and ast.AugStore node classes. (GH-19038)Serhiy Storchaka-100/+43
2020-03-17bpo-39987: Simplify setting lineno in the compiler. (GH-19037)Serhiy Storchaka-50/+18
2020-03-15bpo-39969: Remove ast.Param node class as is no longer used (GH-19020)Batuhan Taşkaya-18/+19
2020-03-15bpo-39965: Correctly raise SyntaxError if await is used outside async ↵Pablo Galindo-4/+8
functions when PyCF_ALLOW_TOP_LEVEL_AWAIT is set (GH-19010)
2020-03-10closes bpo-39922: Remove unused args from four functions. (GH-18893)Andy Lester-17/+17
2020-03-10bpo-34822: Simplify AST for subscription. (GH-9605)Serhiy Storchaka-157/+45
* Remove the slice type. * Make Slice a kind of the expr type instead of the slice type. * Replace ExtSlice(slices) with Tuple(slices, Load()). * Replace Index(value) with a value itself. All non-terminal nodes in AST for expressions are now of the expr type.