summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
Commit message (Collapse)AuthorAgeFilesLines
...
* bpo-42202: Store func annotations as a tuple (GH-23316)Yurii Karabas2020-11-251-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>
* bpo-42349: Compiler clean up. More yak-shaving for PEP 626. (GH-23267)Mark Shannon2020-11-171-60/+127
| | | Make sure that CFG from compiler front-end is correct. Be a bit more aggressive in the compiler back-end.
* bpo-42246: Fix memory leak in compiler (GH-23256)Mark Shannon2020-11-131-7/+13
| | | | | * Fix potential memory leak in assembler init. * Fix reference leak when encountering error during compilation of function body.
* bpo-42246: Eliminate jumps to exit blocks by copying those blocks. (#23251)Mark Shannon2020-11-121-78/+85
| | | * Compiler: eliminate jumps to short exit blocks by copying.
* bpo-42246: Partial implementation of PEP 626. (GH-23113)Mark Shannon2020-11-121-99/+103
| | | * Implement new line number table format, as defined in PEP 626.
* bpo-42161: Use _PyLong_GetZero() and _PyLong_GetOne() (GH-22995)Victor Stinner2020-10-271-2/+4
| | | | Use _PyLong_GetZero() and _PyLong_GetOne() in Objects/ and Python/ directories.
* bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and ↵Serhiy Storchaka2020-10-261-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.
* bpo-38605: Make 'from __future__ import annotations' the default (GH-20434)Batuhan Taskaya2020-10-061-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).
* bpo-39934: Account for control blocks in 'except' in compiler. (GH-22395)Mark Shannon2020-09-251-8/+11
| | | * Account for control blocks in 'except' in compiler. Fixes #39934.
* bpo-40941: Fix fold_tuple_on_constants() compiler warnings (GH-22378)Victor Stinner2020-09-231-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.
* bpo-41746: Add type information to asdl_seq objects (GH-22223)Pablo Galindo2020-09-161-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.
* bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements ↵Pablo Galindo2020-08-131-1/+1
| | | | (GH-21850)
* bpo-41463: Generate information about jumps from 'opcode.py' rather than ↵Mark Shannon2020-08-041-59/+73
| | | | | duplicating it in 'compile.c' (GH-21714) Generate information about jumps from 'opcode.py' rather than duplicate it in 'compile.c'
* bpo-41323: Perform 'peephole' optimizations directly on the CFG. (GH-21517)Mark Shannon2020-07-301-21/+353
| | | * Move 'peephole' optimizations into compile.c and perform them directly on the CFG.
* bpo-41218: Only mark async code with CO_COROUTINE. (#21357)Matthias Bussonnier2020-07-061-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.
* bpo-39151: Simplify DFS in the assembler (GH-17733)Pablo Galindo2020-06-281-33/+18
|
* bpo-40939: Remove the old parser (GH-20768)Pablo Galindo2020-06-111-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.
* Make sure that keyword arguments are merged into the arguments dictionary ↵Mark Shannon2020-06-011-0/+3
| | | | when dict unpacking and keyword arguments are interleaved. (GH-20553)
* bpo-40334: Don't downcast from Py_ssize_t to int (GH-19671)Pablo Galindo2020-04-231-1/+1
|
* bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)Pablo Galindo2020-04-221-0/+67
| | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* bpo-40268: Add _PyInterpreterState_GetConfig() (GH-19492)Victor Stinner2020-04-131-3/+1
| | | | | | | | Don't access PyInterpreterState.config member directly anymore, but use new functions: * _PyInterpreterState_GetConfig() * _PyInterpreterState_SetConfig() * _Py_GetConfig()
* bpo-40147: Fix a compiler warning on Windows in Python/compile.c (GH-19389)Zackery Spytz2020-04-061-4/+5
| | | Change the type of nkeywords to Py_ssize_t.
* bpo-40147: Move the check for duplicate keywords to the compiler (GH-19289)Pablo Galindo2020-04-031-0/+29
|
* bpo-40067: Improve error messages for multiple star expressions in ↵Furkan Önder2020-03-261-1/+1
| | | | | | assignments (GH-19168) Co-Authored-By: Batuhan Taşkaya <isidentical@gmail.com> Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
* bpo-39882: Add _Py_FatalErrorFormat() function (GH-19157)Victor Stinner2020-03-251-16/+12
|
* Use calloc-based functions, not malloc. (GH-19152)Andy Lester2020-03-251-8/+4
|
* bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL ↵Batuhan Taşkaya2020-03-191-2/+5
| | | | | (GH-18968) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-39220: Do not optimise annotation if 'from __future__ import ↵Pablo Galindo2020-03-181-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.
* bpo-39988: Remove ast.AugLoad and ast.AugStore node classes. (GH-19038)Serhiy Storchaka2020-03-171-100/+43
|
* bpo-39987: Simplify setting lineno in the compiler. (GH-19037)Serhiy Storchaka2020-03-171-50/+18
|
* bpo-39969: Remove ast.Param node class as is no longer used (GH-19020)Batuhan Taşkaya2020-03-151-18/+19
|
* bpo-39965: Correctly raise SyntaxError if await is used outside async ↵Pablo Galindo2020-03-151-4/+8
| | | | functions when PyCF_ALLOW_TOP_LEVEL_AWAIT is set (GH-19010)
* closes bpo-39922: Remove unused args from four functions. (GH-18893)Andy Lester2020-03-111-17/+17
|
* bpo-34822: Simplify AST for subscription. (GH-9605)Serhiy Storchaka2020-03-101-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.
* bpo-39890: Don't mutate the AST when compiling starred assignments (GH-18833)Brandt Bucher2020-03-081-2/+4
|
* bpo-39639: Remove the AST "Suite" node and associated code (GH-18513)Batuhan Taşkaya2020-03-041-4/+0
| | | | | | | | The AST "Suite" node is no longer used and it can be removed from the ASDL definition and related structures (compiler, visitors, ...). Co-Authored-By: Victor Stinner <vstinner@python.org> Co-authored-by: Brett Cannon <54418+brettcannon@users.noreply.github.com> Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-32856: Optimize the assignment idiom in comprehensions. (GH-16814)Serhiy Storchaka2020-02-121-18/+52
| | | | | Now `for y in [expr]` in comprehensions is as fast as a simple assignment `y = expr`.
* bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)Victor Stinner2020-02-071-1/+1
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* bpo-39320: Handle unpacking of **values in compiler (GH-18141)Mark Shannon2020-01-271-32/+58
| | | | | | | | | | | | | * 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-96/+107
| | | | | | | | * 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.
* Fix compiler warning on Windows (GH-18012)Ammar Askar2020-01-151-1/+1
| | | | | | | | Python-ast.h contains a macro named Yield that conflicts with the Yield macro in Windows system headers. While Python-ast.h has an "undef Yield" directive to prevent this, it means that Python-ast.h must be included before Windows header files or we run into a re-declaration warning. In commit c96be811fa7d an include for pycore_pystate.h was added which indirectly includes Windows header files. In this commit we re-order the includes to fix this warning.
* bpo-39156: Break up COMPARE_OP into four logically distinct opcodes. (GH-17754)Mark Shannon2020-01-141-27/+44
| | | | | | | | 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.
* Fix handling of line numbers around finally-blocks. (#17737)Mark Shannon2019-12-301-0/+4
|
* bpo-38328: Speed up the creation time of constant list and set display. ↵Brandt Bucher2019-11-261-0/+22
| | | | (GH-17114)
* Produce cleaner bytecode for 'with' and 'async with' by generating separate ↵Mark Shannon2019-11-211-213/+233
| | | | | | 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-38640: Allow break and continue in always false while loops (GH-16992)Pablo Galindo2019-10-301-0/+8
|
* Typo fix: "empy" should be "empty". (GH-16666)Hansraj Das2019-10-091-1/+1
|
* Revert "Fix depth-first-search computation in compile.c (GH-16042)" (GH-16050)T. Wouters2019-09-121-24/+30
| | | | | This reverts commit 355f3e1e5caf16198255df573a1f5e8b98b30105. bpo-38135
* Fix depth-first-search computation in compile.c (GH-16042)Mark Shannon2019-09-121-30/+24
|
* bpo-34880: Add the LOAD_ASSERTION_ERROR opcode. (GH-15073)Zackery Spytz2019-08-251-7/+3
| | | | Fix assert statement misbehavior if AssertionError is shadowed.