Skip to content

Commit 40b75e0

Browse files
authored
Update changelog for 2.3 release (#21728)
Release tracking issue: #21717
1 parent 7ec7d36 commit 40b75e0

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,122 @@
22

33
## Next Release
44

5+
## Mypy 2.3
6+
7+
We've just uploaded mypy 2.3.0 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).
8+
Mypy is a static type checker for Python. This release includes new features, performance
9+
improvements and bug fixes. You can install it as follows:
10+
11+
python3 -m pip install -U mypy
12+
13+
You can read the full documentation for this release on [Read the Docs](http://mypy.readthedocs.io).
14+
15+
### The Upcoming Switch to the New Native Parser
16+
17+
We are planning to enable the new native parser (`--native-parser`) by
18+
default soon. We recommend that you test the native parser in your projects and report
19+
any issues in the [mypy issue tracker](https://github.com/python/mypy/issues).
20+
21+
### Mypyc Free-threading Memory Safety
22+
23+
Free-threaded Python builds that don't have the GIL require additional synchronization
24+
primitives or lock-free algorithms to ensure memory safety when there are race conditions
25+
(for example, when a thread reads a list item while another thread writes the same list
26+
item concurrently). This release greatly improves memory safety of free threading.
27+
28+
List operations are now memory-safe on free threaded Python builds, even in the presence of
29+
race conditions. This has some performance cost. For list-heavy workloads, using
30+
`librt.vecs.vec` instead of list is often significantly faster, but note that `vec` is not
31+
(and likely won't be) fully memory safe, and the user is expected to avoid race conditions.
32+
The newly introduced `librt.threading.Lock` helps with this. Using variable-length tuples
33+
can also be more efficient than lists, since tuples are immutable and don't require
34+
expensive synchronization to ensure memory safety.
35+
36+
Instance attribute access is also (mostly) memory safe now on free-threaded builds in
37+
the presence of race conditions. We are planning to fix the remaining unsafe cases in a
38+
future release.
39+
40+
Full list of changes:
41+
42+
- Make attribute access memory safe on free-threaded builds (Jukka Lehtosalo, PR [21705](https://github.com/python/mypy/pull/21705))
43+
- Fix unsafe borrowing of instance attributes with free-threading (Jukka Lehtosalo, PR [21688](https://github.com/python/mypy/pull/21688))
44+
- Make list get/set item more memory safe on free-threaded builds (Jukka Lehtosalo, PR [21683](https://github.com/python/mypy/pull/21683))
45+
- Don't borrow list items on free-threaded builds (Jukka Lehtosalo, PR [21679](https://github.com/python/mypy/pull/21679))
46+
- Make multiple assignment from list memory-safe on free-threaded builds (Jukka Lehtosalo, PR [21684](https://github.com/python/mypy/pull/21684))
47+
- Make `for` loop over list memory-safe on free-threaded builds (Jukka Lehtosalo, PR [21686](https://github.com/python/mypy/pull/21686))
48+
- Fix memory safety of `list.count` on free-threaded builds (Jukka Lehtosalo, PR [21680](https://github.com/python/mypy/pull/21680))
49+
- Make `vec` creation from list memory safe on free-threaded builds (Jukka Lehtosalo, PR [21681](https://github.com/python/mypy/pull/21681))
50+
51+
### librt.threading: Fast Native Lock Type
52+
53+
Mypyc now supports `librt.threading.Lock`, which is a lock type optimized for use
54+
in compiled code. It can be 2x to 4x faster than `threading.Lock`.
55+
56+
This feature was contributed by Jukka Lehtosalo (PR [21690](https://github.com/python/mypy/pull/21690), PR [21697](https://github.com/python/mypy/pull/21697)).
57+
58+
### Mypyc: Read-only Final Instance Attributes
59+
60+
Instance attributes of native classes declared as `Final` are now read-only at runtime.
61+
This enables additional optimizations, and it's now recommended to use `Final` for
62+
all performance-sensitive attributes when feasible.
63+
64+
Related changes:
65+
66+
- Make instance attribute read-only at runtime if `Final` (Jukka Lehtosalo, PR [21666](https://github.com/python/mypy/pull/21666))
67+
- Borrow final attributes more aggressively (Jukka Lehtosalo, PR [21702](https://github.com/python/mypy/pull/21702))
68+
- Improve documentation of `Final` in mypyc (Jukka Lehtosalo, PR [21713](https://github.com/python/mypy/pull/21713))
69+
70+
### Mypyc Documentation Updates
71+
72+
- Update documentation of race conditions under free threading (Jukka Lehtosalo, PR [21726](https://github.com/python/mypy/pull/21726))
73+
- Update mypyc free threading Python compatibility docs (Jukka Lehtosalo, PR [21711](https://github.com/python/mypy/pull/21711))
74+
- Document recent additions to `librt.strings`, such as `ispace` (Jukka Lehtosalo, PR [21696](https://github.com/python/mypy/pull/21696))
75+
76+
### Miscellaneous Mypyc Improvements
77+
78+
- Fix reference leak when setting unboxed refcounted attributes (Tom Bannink, PR [21657](https://github.com/python/mypy/pull/21657))
79+
- Fix function wrapper memory leak (Piotr Sawicki, PR [21654](https://github.com/python/mypy/pull/21654))
80+
- Fix handling of invalid codepoint values in `librt.strings` (Jukka Lehtosalo, PR [21634](https://github.com/python/mypy/pull/21634))
81+
- Fix non-deterministic ordering of spilled registers (Jukka Lehtosalo, PR [21632](https://github.com/python/mypy/pull/21632))
82+
- Fix non-deterministic compiler output due to frozensets (Jukka Lehtosalo, PR [21631](https://github.com/python/mypy/pull/21631))
83+
84+
### Changes to Messages
85+
86+
- Fix error code of note about unbound type variable (Jukka Lehtosalo, PR [21668](https://github.com/python/mypy/pull/21668))
87+
88+
### Other Notable Fixes and Improvements
89+
90+
- Use `PYODIDE` environment variable for Emscripten cross-compilation detection (Agriya Khetarpal, PR [21714](https://github.com/python/mypy/pull/21714))
91+
- Narrow for frozendict membership check (Shantanu, PR [21709](https://github.com/python/mypy/pull/21709))
92+
- Fix custom equality handling for membership narrowing in static containers (Shantanu, PR [21706](https://github.com/python/mypy/pull/21706))
93+
- Infer `Coroutine` for unannotated async functions (Jingchen Ye, PR [21651](https://github.com/python/mypy/pull/21651))
94+
- Fix variance inference issues caused by dataclass replace (Shantanu, PR [21694](https://github.com/python/mypy/pull/21694))
95+
- Fix regression in dataclass narrowing for Python >= 3.13 (ygale, PR [21675](https://github.com/python/mypy/pull/21675))
96+
- Fix star import dependencies in mypy daemon (Jukka Lehtosalo, PR [21673](https://github.com/python/mypy/pull/21673))
97+
- Fix skipped imports considered stale (Piotr Sawicki, PR [21639](https://github.com/python/mypy/pull/21639))
98+
- Support `.ff` files with `--cache-map` (Jukka Lehtosalo, PR [21633](https://github.com/python/mypy/pull/21633))
99+
100+
### Typeshed Updates
101+
102+
Please see [git log](https://github.com/python/typeshed/commits/main?after=f76037a1eb3923c67a8bc0e302ee9c016ffb3431+0&branch=main&path=stdlib) for full list of standard library typeshed stub changes.
103+
104+
### Acknowledgements
105+
106+
Thanks to all mypy contributors who contributed to this release:
107+
108+
- Agriya Khetarpal
109+
- Ethan Sarp
110+
- Ivan Levkivskyi
111+
- Jingchen Ye
112+
- Jukka Lehtosalo
113+
- Piotr Sawicki
114+
- Shantanu
115+
- Tom Bannink
116+
- Viktor Szépe
117+
- ygale
118+
119+
I'd also like to thank my employer, Dropbox, for supporting mypy development.
120+
5121
## Mypy 2.2
6122

7123
We've just uploaded mypy 2.2.0 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).

0 commit comments

Comments
 (0)