我可以让朱莉娅从REPL中忘记一个方法(Can I make Julia forget a method from the REPL)

编程入门 行业动态 更新时间:2024-10-20 07:59:59
我可以让朱莉娅从REPL中忘记一个方法(Can I make Julia forget a method from the REPL)

如果我在REPL中玩,我为函数定义了几种不同的方法:

julia> methods(next) # 3 methods for generic function "next": next(i::BigInt) at none:1 next(i::Int64) at none:1 next(i) at none:1

我可以让Julia忘记其中的一些或全部吗?

If I'm playing in the REPL and I've defined a few different methods for a function:

julia> methods(next) # 3 methods for generic function "next": next(i::BigInt) at none:1 next(i::Int64) at none:1 next(i) at none:1

Can I make Julia forget some or all of these?

最满意答案

总之,没有。

Julia没有模拟MATLAB的clear功能; 一旦在Julia会话中定义了名称(技术上,在模块Main ),它始终存在。

如果您关注内存使用情况,则始终可以使用内存较少的对象替换对象。 例如,如果A是您不再需要的千兆字节大小的数组,则可以使用A = 0释放内存。 内存将在下次垃圾收集器运行时释放; 你可以用gc()来强制这种情况发生。

( 来源 )

In short, no.

Julia does not have an analog of MATLAB’s clear function; once a name is defined in a Julia session (technically, in module Main), it is always present.

If memory usage is your concern, you can always replace objects with ones that consume less memory. For example, if A is a gigabyte-sized array that you no longer need, you can free the memory with A = 0. The memory will be released the next time the garbage collector runs; you can force this to happen with gc().

(source)

更多推荐

本文发布于:2023-04-29 11:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336332.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   REPL   朱莉   method   forget

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!