Mark Shannon
d87e7f3529
GH-127682: Only call `__iter__` once in generator expressions. (GH-132351)
2025-04-11 09:37:22 +01:00
Jelle Zijlstra
07b8d3117f
gh-132261: Store annotations at hidden internal keys in the class dict ( #132345 )
2025-04-10 21:13:26 -07:00
Irit Katriel
2c8f329dc6
gh-131738: optimize builtin any/all/tuple calls with a generator expression arg ( #131737 )
2025-03-28 10:35:20 +00:00
Jelle Zijlstra
898e6b395e
gh-130881: Handle conditionally defined annotations ( #130935 )
2025-03-26 03:48:19 +00:00
Yan Yanchii
75103d975c
gh-126835: Move constant tuple folding from ast_opt to CFG ( #130769 )
2025-03-19 20:59:55 +00:00
Mark Shannon
a45f25361d
GH-131238: More refactoring of core header files (GH-131351)
...
Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
2025-03-17 14:41:05 +00:00
Yan Yanchii
55815a6474
gh-130480: Move duplicate `LOAD_SMALL_INT` optimization from codegen to CFG ( #130481 )
2025-03-14 21:23:27 +00:00
Irit Katriel
4242c2b8d0
gh-130080: move _Py_EnsureArrayLargeEnough to a separate header so it can be used outside of the compiler ( #130930 )
2025-03-13 16:02:58 +00:00
Yan Yanchii
3618240624
gh-126835: Avoid creating unnecessary tuple when looking for constant sequence during constant folding ( #131054 )
2025-03-12 21:45:54 +00:00
Mark Shannon
be046ee6e0
GH-123044: Give the `POP_TOP` after a case test a location in the body, not the pattern. (GH-130627)
2025-03-10 17:31:16 +00:00
Mark Shannon
89df62c120
GH-128534: Fix behavior of branch monitoring for `async for` (GH-130847)
...
* Both branches in a pair now have a common source and are included in co_branches
2025-03-07 14:30:31 +00:00
Hugo Beauzée-Luyssen
214562ed4d
gh-130740: Move some `stdbool.h` includes after `Python.h` ( #130738 )
...
Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not
included first and when we are in a platform-agnostic context. This is to avoid having
features defined by `stdbool.h` before those decided by `Python.h`.
2025-03-02 09:56:49 +00:00
Mark Shannon
2a18e80695
GH-128534: Instrument branches for `async for` loops. (GH-130569)
2025-02-27 09:36:41 +00:00
Mark Shannon
014223649c
GH-130396: Use computed stack limits on linux (GH-130398)
...
* Implement C recursion protection with limit pointers for Linux, MacOS and Windows
* Remove calls to PyOS_CheckStack
* Add stack protection to parser
* Make tests more robust to low stacks
* Improve error messages for stack overflow
2025-02-25 09:24:48 +00:00
Irit Katriel
a1417b211f
gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR ( #129700 )
2025-02-07 22:39:54 +00:00
Yan Yanchii
0664c1af9b
gh-126835: Move constant subscript folding to CFG ( #129568 )
...
Move folding of constant subscription from AST optimizer to CFG.
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-02-04 10:10:55 +02:00
Kirill Podoprigora
7d0521d5fc
gh-126835: Move optimization of constant sequence creation from codegen to CFG ( #129426 )
...
Codegen phase has an optimization that transforms
```
LOAD_CONST x
LOAD_CONST y
LOAD_CONXT z
BUILD_LIST/BUILD_SET (3)
```
->
```
BUILD_LIST/BUILD_SET (0)
LOAD_CONST (x, y, z)
LIST_EXTEND/SET_UPDATE 1
```
This optimization has now been moved to CFG phase to make #128802 work.
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Yan Yanchii <yyanchiy@gmail.com>
2025-02-01 11:39:44 +00:00
Mark Shannon
75b4962157
GH-128914: Remove all but one conditional stack effects (GH-129226)
...
* Remove all 'if (0)' and 'if (1)' conditional stack effects
* Use array instead of conditional for BUILD_SLICE args
* Refactor LOAD_GLOBAL to use a common conditional uop
* Remove conditional stack effects from LOAD_ATTR specializations
* Replace conditional stack effects in LOAD_ATTR with a 0 or 1 sized array.
* Remove conditional stack effects from CALL_FUNCTION_EX
2025-01-27 16:24:48 +00:00
Sam Gross
a10f99375e
Revert "GH-128914: Remove conditional stack effects from `bytecodes.c` and the code generators (GH-128918)" (GH-129202)
...
The commit introduced a ~2.5-3% regression in the free threading build.
This reverts commit ab61d3f430
.
2025-01-23 09:26:25 +00:00
Mark Shannon
ab61d3f430
GH-128914: Remove conditional stack effects from `bytecodes.c` and the code generators (GH-128918)
2025-01-20 17:09:23 +00:00
Mark Shannon
2434fd2d50
GH-128533: Add `NOT_TAKEN` instruction after bytecode optimization. (GH-128554)
2025-01-06 22:01:07 +00:00
Mark Shannon
f826beca0c
GH-128375: Better instrument for `FOR_ITER` (GH-128445)
2025-01-06 17:54:47 +00:00
Jelle Zijlstra
3480124321
gh-119180: Set the name of the param to __annotate__ to "format" ( #124730 )
2024-12-30 08:19:38 -08:00
Mark Shannon
d2f1d917e8
GH-122548: Implement branch taken and not taken events for sys.monitoring (GH-122564)
2024-12-19 16:59:51 +00:00
Jelle Zijlstra
dcf629213b
gh-119180: Add VALUE_WITH_FAKE_GLOBALS format to annotationlib ( #124415 )
2024-11-26 15:40:13 +00:00
Marc Mueller
4fd9eb2aca
Fix typo: Use AsyncFor element access in codegen ( #127278 )
...
Use AsyncFor element access in codegen
2024-11-26 01:00:46 +00:00
Xuanteng Huang
6ec886531f
gh-126072: Set docstring attribute for module and class ( #126231 )
2024-11-08 15:13:18 +00:00
Bénédikt Tran
c222441fa7
gh-120017: use 'do-while(0)' in some `{codegen,compile}.c` multi-line macros ( #120018 )
2024-11-07 23:03:11 +00:00
Donghee Na
8161afe51c
gh-125832: Reformat comments for inlined comprehensions (gh-126346)
2024-11-03 04:15:07 +00:00
rimchoi
868bfcc02e
gh-125832: Clarify comment for inlined comprehensions as per PEP-709 ( #126322 )
...
* Fix comprehensions comment to inlined by pep 709
* Update spacing
Co-authored-by: RUANG (James Roy) <longjinyii@outlook.com>
* Add reference to PEP 709
---------
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-authored-by: RUANG (James Roy) <longjinyii@outlook.com>
2024-11-02 17:04:53 +00:00
Xuanteng Huang
35df4eb959
gh-126072: do not add `None` to `co_consts` if there is no docstring (GH-126101)
2024-10-30 09:01:09 +00:00
Mark Shannon
faa3272fb8
GH-125837: Split `LOAD_CONST` into three. (GH-125972)
...
* Add LOAD_CONST_IMMORTAL opcode
* Add LOAD_SMALL_INT opcode
* Remove RETURN_CONST opcode
2024-10-29 11:15:42 +00:00
Mikhail Efimov
079875e395
gh-125038: Fix crash after genexpr.gi_frame.f_locals manipulations ( #125178 )
2024-10-22 09:00:25 -07:00
Michael Droettboom
c6127af868
gh-125063: Emit slices as constants in the bytecode compiler ( #125064 )
...
* Make slices marshallable
* Emit slices as constants
* Update Python/marshal.c
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* Refactor codegen_slice into two functions so it
always has the same net effect
* Fix for free-threaded builds
* Simplify marshal loading of slices
* Only return SUCCESS/ERROR from codegen_slice
---------
Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-10-08 13:18:39 -04:00
Irit Katriel
78aeb38f7d
gh-124285: Fix bug where bool() is called multiple times for the same part of a boolean expression ( #124394 )
2024-09-25 15:51:25 +01:00
Irit Katriel
9aa1f60e2d
gh-124058: remove _PyCompile_IsNestedScope, roll it into _PyCompile_IsInteractive ( #124061 )
2024-09-16 06:58:18 -07:00
Irit Katriel
a9594a34c6
gh-124022: Fix bug where class docstring is removed in interactive mode ( #124023 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-09-13 14:06:06 +00:00
Irit Katriel
6e06e01881
gh-124019: do not call codegen_annotations_in_scope if there are no annotations ( #124020 )
2024-09-12 20:24:15 +01:00
Irit Katriel
8145ebea58
gh-124013: remove _PyCompile_IsTopLevelAwait ( #124014 )
2024-09-12 19:58:32 +01:00
Irit Katriel
e07154fd1e
gh-123958: apply docstring removal optimization in ast_opt instead of codegen ( #123959 )
2024-09-11 17:02:28 +00:00
Irit Katriel
a2d0818c85
gh-123881: make compiler add the .generic_base base class without constructing AST nodes ( #123883 )
2024-09-10 16:16:00 +00:00
Irit Katriel
1a9d8917a3
gh-121404: split compile.c into compile.c and codegen.c ( #123651 )
2024-09-09 18:21:51 +01:00