-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
asyncio: fix import #7267
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
asyncio: fix import #7267
Conversation
FYI, the reasoning behind the current implementation was discussed at #5332 (review) |
@dlech: as far as I understand the discussion is around problems for IDE tooling etc. But what I ran into is a real bug. As far as I understand the lazy import was predominantly done to save memory. But I have not seen any evidence/numbers how much good that does in reality. In my personal experience I have not seen problems from overhead of imports in frozen code. There are other "things" which are much more likely to result in memory problems. So where does that leave us with this bug? I can see two options: apply the fix or write up some documentation how to work around the issues. |
Yes the main goal was memory saving (afaik). There is no need for absolute numbers in my opinion but you can easily check. It saves some bytes for every module you don't use. On most platforms this might be irrelevant and even on an esp8266 I would be able to live with 500Bytes less but why waste RAM? I can see that the lazy import doesn't work in your use-case but in my opinion that's an acceptable problem because your use-case isn't a recommended way of programming either: See pep8:
|
@kevinkk525 There is a good reason why I need the When it comes to premature optimization I am all for numbers to do informed decisions. Here are some for the ESP32 Wroom:
A typical use case is to pull in |
Well if you have a good reason (please tell us), then you could simply do the exports differently because you'll likely be the only one to use a wildcard import on uasyncio.
Or is there a reason not to do that? I see a savings of almost 2k if no stream,funcs,event or lock is being used. That is a significant amount. Maybe not on your esp32 wroom and in your project but overall, 2k is quite something. Of course I'm just another developer. Personally I just don't see a need here to fix a problem that maybe 0.8% of all users might encounter and can easily work around, while giving everyone else a disadvantage of up to 2k more RAM usage. |
False! Correct: those importing |
@kevinkk525 I believe discussions about workarounds should be made in the corresponding issue. But it is anyways trivial and really no need for that. Costly it is for others to run into a bug and find the reason. This PR is about that. No more no less. The disadvantages in numbers are listed above. The maintainers should be able to decide whether to include the PR or reject it. |
Bear in mind that |
I think the right way to solve this is to fix Thanks for the PR and discussion! |
fixes #7266