Skip to content
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

The lazy Images package with dependencies loading delayed #1009

Open
johnnychen94 opened this issue May 17, 2022 · 0 comments
Open

The lazy Images package with dependencies loading delayed #1009

johnnychen94 opened this issue May 17, 2022 · 0 comments
Labels

Comments

@johnnychen94
Copy link
Member

johnnychen94 commented May 17, 2022

A recent PR in JuliaML/MLDatasets.jl#128 raises the need to make dependency loading lazily so that the overall @time using XXX for whatever umbrella package as fast as possible.
For this reason, I created LazyModules.jl, it's quite convenient to use, but requires a careful handle of the world-age issues.

A typical use case of @lazy macro is a black box package where we don't require the internal types. For instance,

using ImageMorphology

img = rand(RGB, 64, 64)
erode(img)

Here the erode function is a perfect example: it doesn't output alien types to the caller. Thus we can try to @lazy import ImageMorphology so that users who don't require morphological features don't need to pay for the latency of ImageMorphology.

To properly achieve this without breaking people's code, we'll need to revisit the internal types and ensure that necessary core types and methods are eagerly loaded. As an outcome, there might be a few new "Core" packages, e.g., ImageMorphologyCore.


This trick is adopted in FileIO and ImageIO for many years and it's working quite well (except that occasionally people hit world-age issues because the supporting packages output alien types). With the new LazyModules, it's perhaps a good idea to adopt this
trick more widely to JuliaImages and perhaps other ecosystems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant