【发布时间】:2018-10-20 00:00:53
【问题描述】:
Julia 中的objectid()、hash()、pointer() 和 pointer_from_objref() 有什么区别?
与===比较的运算符是什么?
julia> L1 = [1,2,3];
julia> L2 = L1;
julia> L3 = copy(L1);
julia> objectid(L1), objectid(L2), objectid(L3)
(0xac55c2b098913d98, 0xac55c2b098913d98, 0xbdee7946bbc068f0)
julia> hash(L1), hash(L2), hash(L3)
(0xecc5186e7be222c6, 0xecc5186e7be222c6, 0xecc5186e7be222c6)
julia> pointer_from_objref(L1), pointer_from_objref(L2), pointer_from_objref(L3)
(Ptr{Nothing} @0x00007f6888141e40, Ptr{Nothing} @0x00007f6888141e40, Ptr{Nothing} @0x00007f68881438f0)
julia> pointer(L1), pointer(L2), pointer(L3)
(Ptr{Int64} @0x00007f6888141e80, Ptr{Int64} @0x00007f6888141e80, Ptr{Int64} @0x00007f6888143930)
来自文档:
objectid(x)
Get a hash value for x based on object identity. objectid(x)==objectid(y) if x === y.
hash(x[, h::UInt])
Compute an integer hash code such that isequal(x,y) implies hash(x)==hash(y).
pointer_from_objref(x)
Get the memory address of a Julia object as a Ptr.
pointer(array [, index])
Get the native address of an array or string, optionally at a given location index.
【问题讨论】:
-
文档是怎么说的?阅读文档后,还有哪些问题?关于阅读的文档,详细展开这些问题。
-
这就是我问的原因,因为我不懂文档!
标签: julia