Julia 的 `hash()` 函数是否保证跨会话、平台和版本具有稳定的输出? [英] Is Julia's `hash()` function guaranteed to have a stable output across sessions, platforms and versions?

查看:17
本文介绍了Julia 的 `hash()` 函数是否保证跨会话、平台和版本具有稳定的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在多个不同的 Julia REPL 会话中运行以下代码,在 MacOSX 和 Linux 上,我总是得到完全相同的输出:

I tried running the following code in multiple different Julia REPL sessions, on MacOSX and Linux, and I always got the exact same outputs:

julia> hash(123), hash("123"), hash([1,2,3]), hash((1,2,3)), hash(Set([1,2,3])), hash(:123)
(0x54657e9dbfd649e5, 0xb4e92987fa06fcab, 0xecc5186e7be222c6, 0xafc764e9c2b7cde5, 0x66406071c4c9b92a,
0x54657e9dbfd649e5)

问题:语言是否保证了这种行为?或者输出是否会有所不同(就像在 Python 中一样,跨会话、平台和版本)?

注意:这个问题与我的 其他问题关于SetDict等基于散列的集合顺序的稳定性(密切相关,但不同).

Note: this question is related to my other question about the stability of the order of hash-based collections such as Set and Dict (it's closely related, but different).

推荐答案

它们不稳定,可能会因版本或平台而异.它们在不同字长的系统之间已经不同了.

They are not stable and can change from version to version or platforms. They are already different between systems with different word sizes.

这篇关于Julia 的 `hash()` 函数是否保证跨会话、平台和版本具有稳定的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆