Julia中的模块别名 [英] Module aliasing in Julia
本文介绍了Julia中的模块别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在python中,您可以执行以下操作来使用简短的模块名称:
In python you can do something like this to let you use a shortened module name:
>>> import tensorflow as tf
从那时起,您可以引用tf
,而不必在任何地方键入tensorflow
.
From then on you can refer to tf
, instead of having to type tensorflow
everywhere.
在朱拉(Juila)这样的事情有可能发生吗?
Is something like this possible in Juila?
推荐答案
是的,您只需将模块分配给新名称即可.
Yep, you can just assign the module to a new name.
import JSON
const J = JSON
J.print(Dict("Hello, " => "World!"))
我强烈建议使用const
,否则会导致性能下降. (使用const
时,不会降低性能.)
I highly recommend to use the const
because otherwise there will be a performance penalty. (With the const
, there is no performance penalty.)
这篇关于Julia中的模块别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文