Skip to content

Commit ffb8eef

Browse files
authored
Merge branch 'master' into fix-mypyc-incremental-cross-group-header-deps
2 parents c30c9ad + 488a646 commit ffb8eef

6 files changed

Lines changed: 64 additions & 16 deletions

File tree

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ tox -e dev --override testenv:dev.allowlist_externals+=env -- env # inspect the
123123
If you don't already have `tox` installed, you can use a virtual environment as
124124
described above to install `tox` via `pip` (e.g., ``python -m pip install tox``).
125125

126+
## LLM-assisted contributions
127+
128+
In general, mypy takes a neutral stance on using various LLM code assistants to
129+
make contributions. LLMs are just another tool, and contributors bear full
130+
responsibility for the code they are submitting. Disclosing the use of LLMs in
131+
pull request description is recommended, but not required.
132+
133+
However, we discourage use of LLMs by *new* contributors. We are interested in
134+
growing long-term contributors who have good understanding of mypy code.
135+
Pull requests from new contributors that are mostly generated by LLMs
136+
with little human input will be closed.
137+
126138
## First time contributors
127139

128140
If you're looking for things to help with, browse our [issue tracker](https://github.com/python/mypy/issues)!

mypy-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ mypy_extensions>=1.0.0
66
pathspec>=1.0.0
77
tomli>=1.1.0; python_version<'3.11'
88
librt>=0.11.0; platform_python_implementation != 'PyPy'
9-
ast-serialize>=0.4.0,<1.0.0
9+
ast-serialize>=0.5.0,<1.0.0

mypyc/doc/differences_from_python.rst

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,45 @@ When run as interpreted, the first example will execute slower due to
260260
the extra namespace lookups. In interpreted code final attributes can
261261
also be modified.
262262

263+
.. _free-threading:
264+
265+
Free threading
266+
--------------
267+
268+
Mypyc has basic support for free threading, but it doesn't provide the
269+
same memory safety guarantees as Python in compiled modules, since
270+
in current Python versions this would cause an unacceptable performance
271+
impact.
272+
273+
The exact details of the memory safety in the presence of data races
274+
are likely to evolve in the future. Currently, compiled code must
275+
ensure that proper synchronization is used to prevent data races. In
276+
particular, these operations require explicit synchronization, such as
277+
via ``threading.Lock``, if there is a possibility of data races
278+
(the list is not exhaustive):
279+
280+
* Reads or writes of non-final instance data attributes of native
281+
classes.
282+
* List item access or iteration using a ``list`` static type (using
283+
``Sequence`` or ``MutableSequence`` as the type ensure correct
284+
implicit synchronization).
285+
* Dict item access using a static ``dict`` type (using ``Mapping``
286+
or ``MutableMapping`` ensures correct implicit synchronization).
287+
288+
As libraries often won't be able to control the concurrent access by
289+
user code, we recommend that modules document that multi-threaded
290+
access is only supported via public interfaces that ensure correct
291+
synchronization. Marking attributes as internal using an underscore
292+
attribute prefix is another possibility, but this is not enforced at
293+
runtime. Another option is to document that multithreaded access is
294+
not supported, or that particular objects should not be used from
295+
multiple threads concurrently.
296+
297+
It's always safe to perform read-only operations concurrently. Using
298+
objects with final attributes and tuple objects can help prevent
299+
race conditions without introducing extra overhead from explicit
300+
synchronization operations.
301+
263302
Unsupported features
264303
--------------------
265304

@@ -284,10 +323,8 @@ Dunder methods
284323
Native classes **cannot** use these dunders. If defined, they will not
285324
work as expected.
286325

287-
* ``__del__``
288326
* ``__index__``
289-
* ``__getattr__``, ``__getattribute__``
290-
* ``__setattr__``
327+
* ``__getattribute__``
291328
* ``__delattr__``
292329

293330
Generator expressions
@@ -318,7 +355,6 @@ non-exhaustive list of what won't work:
318355
- Compiled methods aren't considered methods by ``inspect.ismethod``
319356
- ``inspect.signature`` chokes on compiled functions with default arguments that
320357
are not simple literals
321-
- ``inspect.iscoroutinefunction`` and ``asyncio.iscoroutinefunction`` will always return False for compiled functions, even those defined with `async def`
322358

323359
Profiling hooks and tracing
324360
***************************

mypyc/doc/introduction.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ also as normal, interpreted Python modules.
2323
Existing code with type annotations is often **1.5x to 5x** faster
2424
when compiled. Code tuned for mypyc can be **5x to 10x** faster.
2525

26-
Mypyc currently aims to speed up non-numeric code, such as server
27-
applications. Mypyc is also used to compile itself (and mypy).
26+
Mypyc aims to be effective in many common use cases, including
27+
server applications. Mypyc is also used to compile itself (and mypy).
2828

2929
Why mypyc?
3030
----------
@@ -54,10 +54,11 @@ requires only minor changes to compile using mypyc.
5454
normal Python code. You can use interpreted Python during development,
5555
with familiar and fast workflows.
5656

57-
**Runtime type safety.** Mypyc protects you from segfaults and memory
58-
corruption. Any unexpected runtime type safety violation is a bug in
59-
mypyc. Runtime values are checked against type annotations. (Without
60-
mypyc, type annotations are ignored at runtime.)
57+
**Runtime type safety.** Mypyc partially protects you from segfaults and
58+
memory corruption (see :ref:`free-threading` for limitations). Any
59+
unexpected runtime type safety violation is a bug in mypyc. Runtime
60+
values are checked against type annotations. (Without mypyc, type
61+
annotations are ignored at runtime.)
6162

6263
**Find errors statically.** Mypyc uses mypy for static type checking
6364
that helps catch many bugs.
@@ -110,8 +111,7 @@ differently, however:
110111
* Mypyc performs strict enforcement of type annotations at runtime,
111112
resulting in better runtime type safety and easier debugging.
112113

113-
Unlike Cython, mypyc doesn't directly support interfacing with C libraries
114-
or speeding up numeric code.
114+
Unlike Cython, mypyc doesn't directly support interfacing with C libraries.
115115

116116
How does it work
117117
----------------

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ requires = [
1515
"types-psutil",
1616
"types-setuptools",
1717
# required to work around a mypyc import bug
18-
"ast-serialize>=0.4.0,<1.0.0",
18+
"ast-serialize>=0.5.0,<1.0.0",
1919
]
2020
build-backend = "setuptools.build_meta"
2121

@@ -59,7 +59,7 @@ dependencies = [
5959
"pathspec>=1.0.0",
6060
"tomli>=1.1.0; python_version<'3.11'",
6161
"librt>=0.11.0; platform_python_implementation != 'PyPy'",
62-
"ast-serialize>=0.4.0,<1.0.0",
62+
"ast-serialize>=0.5.0,<1.0.0",
6363
]
6464
dynamic = ["version"]
6565

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# pip-compile --allow-unsafe --output-file=test-requirements.txt --strip-extras test-requirements.in
66
#
7-
ast-serialize==0.4.0
7+
ast-serialize==0.5.0
88
# via -r mypy-requirements.txt
99
attrs==26.1.0
1010
# via -r test-requirements.in

0 commit comments

Comments
 (0)