summaryrefslogtreecommitdiff
path: root/Python/importlib_external.h
AgeCommit message (Collapse)AuthorLines
2021-08-30bpo-45019: Add a tool to generate list of modules to include for frozen ↵Eric Snow-3604/+0
modules (gh-27980) Frozen modules must be added to several files in order to work properly. Before this change this had to be done manually. Here we add a tool to generate the relevant lines in those files instead. This helps us avoid mistakes and omissions. https://bugs.python.org/issue45019
2021-08-12bpo-44885: Correct the ast locations of f-strings with format specs and ↵Pablo Galindo Salgado-12/+12
repeated expressions (GH-27729)
2021-08-09bpo-44840: Compiler: Move duplication of exit blocks with no line numbers to ↵Mark Shannon-3180/+3175
after CFG optimization. (GH-27656)
2021-07-15bpo-44626: Merge basic blocks earlier to enable better handling of exit ↵Mark Shannon-2831/+2833
blocks without line numbers (GH-27138)
2021-07-07bpo-44530: Add co_qualname field to PyCodeObject (GH-26941)Gabriele N. Tornetta-3352/+3328
2021-07-02bpo-43950: Add code.co_positions (PEP 657) (GH-26955)Pablo Galindo-2448/+3270
This PR is part of PEP 657 and augments the compiler to emit ending line numbers as well as starting and ending columns from the AST into compiled code objects. This allows bytecodes to be correlated to the exact source code ranges that generated them. This information is made available through the following public APIs: * The `co_positions` method on code objects. * The C API function `PyCode_Addr2Location`. Co-authored-by: Batuhan Taskaya <isidentical@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
2021-07-01bpo-44313: bump up magic (#26983)Batuhan Taskaya-1/+1
2021-06-30bpo-44313: generate LOAD_ATTR/CALL_FUNCTION for top-level imported objects ↵Batuhan Taskaya-172/+172
(GH-26677)
2021-06-24Make sure that line number is set correctly for call to __exit__ when ↵Mark Shannon-2436/+2436
handling exception in body of a with statement. (GH-26890)
2021-06-23bpo-43693 Get rid of CO_NOFREE -- it's unused (GH-26839)Guido van Rossum-116/+116
All uses of this flag are either setting it or in doc or tests for it. So we should be able to get rid of it completely.
2021-06-21bpo-43693: Turn localspluskinds into an object (GH-26749)Guido van Rossum-2546/+2587
Managing it as a bare pointer to malloc'ed bytes is just too awkward in a few places.
2021-06-21bpo-44297: Fix missing line number in generator expressions (GH-26801)Mark Shannon-952/+952
* Make sure that line number is set when entering comprehension scope in compiler.
2021-06-15bpo-43693: Eliminate unused "fast locals". (gh-26587)Eric Snow-2504/+2503
Currently, if an arg value escapes (into the closure for an inner function) we end up allocating two indices in the fast locals even though only one gets used. Additionally, using the lower index would be better in some cases, such as with no-arg `super()`. To address this, we update the compiler to fix the offsets so each variable only gets one "fast local". As a consequence, now some cell offsets are interspersed with the locals (only when an arg escapes to an inner function). https://bugs.python.org/issue43693
2021-06-12Fix typos in multiple files (GH-26689)Binbin-992/+992
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-06-08 bpo-43693: Un-revert commit f3fa63e. (#26609)Eric Snow-2631/+2632
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
2021-06-08Revert "bpo-43693: Add the MAKE_CELL opcode and interleave fast locals ↵Pablo Galindo-2632/+2631
offsets. (gh-26396)" (GH-26597) This reverts commit 631f9938b1604d4f893417ec339b9e0fa9196fb1.
2021-06-07bpo-43693: Add the MAKE_CELL opcode and interleave fast locals offsets. ↵Eric Snow-2631/+2632
(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
2021-06-07bpo-43693: Un-revert commits 2c1e258 and b2bf2bc. (gh-26577)Eric Snow-2666/+2616
These were reverted in gh-26530 (commit 17c4edc) due to refleaks. * 2c1e258 - Compute deref offsets in compiler (gh-25152) * b2bf2bc - Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388) This change fixes the refleaks. https://bugs.python.org/issue43693
2021-06-04bpo-43693: Revert commits 2c1e2583fdc4db6b43d163239ea42b0e8394171f and ↵Pablo Galindo-2616/+2666
b2bf2bc1ece673d387341e06c8d3c2bc6e259747 (GH-26530) * Revert "bpo-43693: Compute deref offsets in compiler (gh-25152)" This reverts commit b2bf2bc1ece673d387341e06c8d3c2bc6e259747. * Revert "bpo-43693: Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388)" This reverts commit 2c1e2583fdc4db6b43d163239ea42b0e8394171f. These two commits are breaking the refleak buildbots.
2021-06-03bpo-43693: Compute deref offsets in compiler (gh-25152)Mark Shannon-126/+126
Merges locals and cells into a single array. Saves a pointer in the interpreter and means that we don't need the LOAD_CLOSURE opcode any more https://bugs.python.org/issue43693
2021-06-03bpo-43693: Add new internal code objects fields: co_fastlocalnames and ↵Eric Snow-2665/+2615
co_fastlocalkinds. (gh-26388) A number of places in the code base (notably ceval.c and frameobject.c) rely on mapping variable names to indices in the frame "locals plus" array (AKA fast locals), and thus opargs. Currently the compiler indirectly encodes that information on the code object as the tuples co_varnames, co_cellvars, and co_freevars. At runtime the dependent code must calculate the proper mapping from those, which isn't ideal and impacts performance-sensitive sections. This is something we can easily address in the compiler instead. This change addresses the situation by replacing internal use of co_varnames, etc. with a single combined tuple of names in locals-plus order, along with a minimal array mapping each to its kind (local vs. cell vs. free). These two new PyCodeObject fields, co_fastlocalnames and co_fastllocalkinds, are not exposed to Python code for now, but co_varnames, etc. are still available with the same values as before (though computed lazily). Aside from the (mild) performance impact, there are a number of other benefits: * there's now a clear, direct relationship between locals-plus and variables * code that relies on the locals-plus-to-name mapping is simpler * marshaled code objects are smaller and serialize/de-serialize faster Also note that we can take this approach further by expanding the possible values in co_fastlocalkinds to include specific argument types (e.g. positional-only, kwargs). Doing so would allow further speed-ups in _PyEval_MakeFrameVector(), which is where args get unpacked into the locals-plus array. It would also allow us to shrink marshaled code objects even further. https://bugs.python.org/issue43693
2021-06-03bpo-44298: Fix line numbers for early exits in with statements. (GH-26513)Mark Shannon-1194/+1194
2021-05-27bpo-43693: Add _PyCode_New(). (gh-26375)Eric Snow-2204/+2172
This is an internal-only API that helps us manage the many values used to create a code object. https://bugs.python.org/issue43693
2021-05-15bpo-26110: Add ``CALL_METHOD_KW`` opcode to speedup method calls with ↵Ken Jin-123/+123
keywords (GH-26014) * Add CALL_METHOD_KW * Make CALL_METHOD branchless too since it shares the same code * Place parentheses in STACK_SHRINK
2021-05-12bpo-43933: Force RETURN_VALUE bytecodes to have line numbers (GH-26054)Mark Shannon-1209/+1209
2021-05-08bpo-28307: Convert simple C-style formatting with literal format into ↵Serhiy Storchaka-2162/+2162
f-string. (GH-5012) C-style formatting with literal format containing only format codes %s, %r and %a (with optional width, precision and alignment) will be converted to an equivalent f-string expression. It can speed up formatting more than 2 times by eliminating runtime parsing of the format string and creating temporary tuple.
2021-05-07bpo-40222: "Zero cost" exception handling (GH-25729)Mark Shannon-2448/+2531
"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%.
2021-05-02bpo-43754: Eliminate bindings for partial pattern matches (GH-25229)Brandt Bucher-110/+110
2021-04-30bpo-43933: Set frame.f_lineno during call to __exit__ (GH-25719)Mark Shannon-1643/+1644
* Set line number of __exit__ call in a with statement to be that of the with keyword.
2021-04-29bpo-42739: Don't use sentinels to mark end of line table. (GH-25657)Mark Shannon-2405/+2391
* Add length parameter to PyLineTable_InitAddressRange and doen't use sentinel values at end of table. Makes the line number table more robust. * Update PyCodeAddressRange to match PEP 626.
2021-04-21bpo-38605: Revert making 'from __future__ import annotations' the default ↵Pablo Galindo-110/+110
(GH-25490) This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.
2021-04-16bpo-41323: compiler: Reuse tuple in constant tuple folding (GH-25419)Inada Naoki-2083/+2083
2021-04-07bpo-43105: Importlib now resolves relative paths when creating module spec ↵Steve Dower-2436/+2494
objects from file locations (GH-25121)
2021-04-06bump the bytecode magic number (GH-25225)Dennis Sweeney-1/+1
2021-04-06bpo-42135: Deprecate implementations of find_module() and find_loader() ↵Brett Cannon-2003/+2035
(GH-25169)
2021-04-06bpo-43683: Handle generator entry in bytecode (GH-25138)Mark Shannon-2584/+2585
* Handle check for sending None to starting generator and coroutine into bytecode. * Document new bytecode and make it fail gracefully if mis-compiled.
2021-04-04bpo-27129: Update magic numbers and bootstrapping for GH-25069 (GH-25172)Dennis Sweeney-1/+1
* Update magic numbers and bootstrapping for GH-25069 * add blurb Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-04-02bpo-43672: raise ImportWarning when calling find_loader() (GH-25119)Brett Cannon-523/+528
2021-04-01bpo-27129: Use instruction offsets, not byte offsets, in bytecode and ↵Mark Shannon-2638/+2635
internally. (GH-25069) * Use instruction offset, rather than bytecode offset. Streamlines interpreter dispatch a bit, and removes most EXTENDED_ARGs for jumps. * Change some uses of PyCode_Addr2Line to PyFrame_GetLineNumber
2021-03-30bpo-42134: Raise ImportWarning when calling find_module() in the import ↵Brett Cannon-515/+523
system (GH-25044)
2021-03-26bpo-42136: Deprecate module_repr() as found in importlib (GH-25022)Brett Cannon-696/+704
2021-03-14bpo-39316: Make sure that attribute accesses and stores, including method ↵Mark Shannon-2/+2
calls, conform to PEP 626. (GH-24859)
2021-03-04bpo-42129: Add support for resources in namespaces (GH-24670)Jason R. Coombs-730/+742
* Unify behavior in ResourceReaderDefaultsTests and align with the behavior found in importlib_resources. * Equip NamespaceLoader with a NamespaceReader. * Apply changes from importlib_resources 5.0.4
2021-02-26bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)Brandt Bucher-109/+109
Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Talin <viridia@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2021-02-10bpo-42217: compiler: merge same co_code and co_linetable objects (GH-23056)Inada Naoki-2254/+2240
2021-01-13bpo-42908: Mark cleanup code at end of try-except and with artificial (#24202)Mark Shannon-2245/+2244
* 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-1134/+1134
* 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-1239/+1239
* Mark jumps at end of if and try statements as artificial. * Update importlib * Add comment explaining the purpose of ADDOP_JUMP_NOLINE.
2020-12-23bpo-42246: Don't eliminate jumps to jumps, if it will break PEP 626. (GH-23896)Mark Shannon-2441/+2443
2020-12-21bpo-42634: Mark reraise after except blocks as artificial. (GH-23877)Mark Shannon-2404/+2407
* Mark reraise after except blocks as artificial. * Update importlib * Update dis test.