I thought it might be better to continue the discussion in a new thread. To kick things off, here’s a very rough notebook that creates a diagram of notebook imports. (Suggestions, questions, comments all very welcome!)
If we suppose that there aren’t any bugs (a big ask, admittedly), the diagram depicts all the different “modules” created when the notebook is loaded, colored according to whether they are created via an import, created via “
.derive”, or created indirectly via “
.derive” by copying dependencies.
As an aside, I noticed that the
_builtin module (containing stdlib functions) is also copied via
module_copy. I could be wrong, but it seems to me like this is unnecessary — it should be OK to simply import variables from the original
_builtin module. You can play around with a proposed fix for this in the above notebook as well here. This probably doesn’t make a big difference in performance though.
Edit: I’ve updated the diagram so that you can click on a module to display the cells in an adaptation of @mike’s Notebook Visualizer beneath it.