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

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

问题描述

我尝试在MacOSX和Linux的多个不同的Julia REPL会话中运行以下代码,并且始终获得完全相同的输出:

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中那样,跨会话,平台和版本)?

注意:此问题与我的

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天全站免登陆