docs/reference/speed_python: Document schedule/GIL limitation of native.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2025-07-17 15:04:14 +10:00
parent b070765427
commit 677a0e0124

View file

@ -246,6 +246,13 @@ There are certain limitations in the current implementation of the native code e
* Context managers are not supported (the ``with`` statement).
* Generators are not supported.
* If ``raise`` is used an argument must be supplied.
* The background scheduler (see `micropython.schedule`) is not run during
execution of native code.
* On targets with thrteading and the GIL, the GIL is not released during
execution of native code.
To mitigate the last two points, long running native functions should call
``time.sleep(0)`` periodically, which will run the scheduler and bounce the GIL.
The trade-off for the improved performance (roughly twice as fast as bytecode) is an
increase in compiled code size.