-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
all: Rename uasyncio
to asyncio
.
#11740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Code size report:
|
Codecov Report
@@ Coverage Diff @@
## master #11740 +/- ##
=======================================
Coverage 98.40% 98.40%
=======================================
Files 155 155
Lines 20543 20543
=======================================
Hits 20215 20215
Misses 328 328
|
Strange that there is such a large increase in code size... |
It's entirely the We could maybe add a reverse-weak-links-for-frozen-modules feature (i.e. an |
Yes, if it's purely done for backwards compatibility and there's a way to do it in fewer bytes in C, then I think we should try that. |
An alias is a bit tricky because there are 7 asyncio modules frozen. A very simple option is to detect an import path starting with uasyncio and map it. e.g. in builtinimport.c #if MICROPY_PY_ASYNCIO
// If the import is for "uasyncio" or "uasyncio/...", then map to "asyncio".
if (strncmp(module_name, "uasyncio", 8) == 0 && (module_name[8] == '.' || module_name[8] == 0)) {
++module_name;
--module_name_len;
}
#endif This comes out about 100 bytes better than adding You could also do this in frozenmod.c but then you have a situation where |
Let's keep the frozen |
The asyncio module now has much better CPython compatibility and deserves to be just called "asyncio". This will avoid people having to write `from uasyncio import asyncio`. Renames all files, and updates port manifests to use the new path. Also renames the built-in _uasyncio to _asyncio. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Mostly updates comments, but also renames the UASYNCIO enum value to ASYNCIO. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This allows existing code that does `import uasyncio` or `import uasyncio as asyncio` to continue working. It uses the same lazy-loading as asyncio to prevent loading of unused features. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Merged! |
I'm very happy this has been merged, thanks @jimmo Minor note for anyone playing along at home - I have an existing project where I wanted compatibility with an existing cpython library using
before importing the external library, such that when it does With micropython updated to include this MR, well my snippet above blows up with an infinite recurtion error in the new |
With the recent MicroPython change to remove the u prefix by default on builtins (micropython/micropython#11740) the format checker in fnmatch which was detecting ure no longer works. This commit updates the module to filter the regex automatically as needed. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Follow up to #9018 (and #9069)
It's CPython-compatible enough that it deserves to be called
asyncio
. I don't want to see any more code that doesimport uasyncio as asyncio
.This PR replaces
uasyncio
withasyncio
everywhere, renames files, etc. A tiny lazy-loadinguasyncio.py
is added to the frozen manifest that allows for backwards compatibility with existing code.This work was funded through GitHub Sponsors.