gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 02:22:05 24 4
gpt4 key购买 nike

在 Python 中,您可以使用 as 关键字导入具有任何名称的模块。 Julia 中有类似的东西吗?

显然你可以这样做

import moduleWithReallyLongName
M = moduleWithReallyLongName

有更好的方法吗?

最佳答案

import moduleWithReallyLongName
const M = moduleWithReallyLongName

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

另一个选项是包ImportMacros.jl ( https://github.com/fredrikekre/ImportMacros.jl )

using ImportMacros
@import moduleWithReallyLongName as M

关于julia - 导入具有不同名称的 Julia 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52175339/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com