首页 文章

导入具有不同名称的Julia模块

提问于
浏览
4

在Python中,您可以使用 as 关键字导入具有所需名称的模块 . 朱莉娅有同样的东西吗?

显然你可以做到

import moduleWithReallyLongName
M = moduleWithReallyLongName

有没有更好的办法?

1 回答

  • 8
    import moduleWithReallyLongName
    const M = moduleWithReallyLongName
    

    请注意const的用法 . 根据经验,Julia中的任何全局变量都应该是类型稳定的,否则您将观察到性能降低 .

    另一种选择是包 ImportMacros.jlhttps://github.com/fredrikekre/ImportMacros.jl

    using ImportMacros
    @import moduleWithReallyLongName as M
    

相关问题