implement Lazy Loading for Cocoa core imports
Fixes (partly) https://github.com/beeware/toga/issues/2547
PR Checklist:
- [ x] All new features have been tested
- [ x] All new features have been documented
- [x ] I have read the CONTRIBUTING.md file
- [x ] I will abide by the code of conduct
I'm not sure if you're aware of how to run the testbed on your own machine, but there are instructions here.
Also - as @johnzhou721 has noted, the
test_importthat you've added won't ever be executed. That said - if the lazy import is done right, it won't need any additional tests - because the existing codebase is testing every valid import. All this change would do is modify how that import is implemented, making it (hopefully) faster.
Agreed. But I think we should have an explicict test about failed imports. Cocoa has now achieved 100% functionality coverage, so there's no Cocoa backend doesn't implement messages that come up, and we still need to verify that this functionality w/ doesn't impl messsages work correctly.
Agreed. But I think we should have an explicict test about failed imports. Cocoa has now achieved 100% functionality coverage, so there's no
Cocoa backend doesn't implementmessages that come up, and we still need to verify that this functionality w/doesn't implmesssages work correctly.
Sure - but that's more of a "filling a testing gap that is currently hidden", rather than anything directly related to this PR. I've added #3632 to track this as an idea.
Wow... didn't realize it wasn't covered now!!! My eyes tend to ignore gray things (comments in Xcode as I don't even have a proper IDE just random apps that happens to open Python files), I guess.
if the lazy import is done right, it won't need any additional tests - because the existing codebase is testing every valid import. All this change would do is modify how that import is implemented, making it (hopefully) faster.
As we discussed in the toga-core lazy import PR, we should still have a test if possible, otherwise it would be easy to reintroduce an eager import by accident and not notice for years. The same approach can be used in this PR.