Skip to content

Commit 6412f06

Browse files
committed
rename object_id to objectid
1 parent 468f097 commit 6412f06

File tree

16 files changed

+40
-38
lines changed

16 files changed

+40
-38
lines changed

base/asyncmap.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ then be a function that must accept a `Vector` of argument tuples and must
2323
return a vector of results. The input vector will have a length of `batch_size` or less.
2424
2525
The following examples highlight execution in different tasks by returning
26-
the `object_id` of the tasks in which the mapping function is executed.
26+
the `objectid` of the tasks in which the mapping function is executed.
2727
2828
First, with `ntasks` undefined, each element is processed in a different task.
2929
```
30-
julia> tskoid() = object_id(current_task());
30+
julia> tskoid() = objectid(current_task());
3131
3232
julia> asyncmap(x->tskoid(), 1:5)
3333
5-element Array{UInt64,1}:

base/deprecated.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2799,6 +2799,8 @@ end
27992799

28002800
@deprecate method_exists hasmethod
28012801

2802+
@deprecate object_id objectid
2803+
28022804
# issue #9053
28032805
if Sys.iswindows()
28042806
function Filesystem.tempname(uunique::UInt32)

base/exports.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ export
788788
isimmutable,
789789
isless,
790790
ifelse,
791-
object_id,
791+
objectid,
792792
sizeof,
793793

794794
# tasks and conditions

base/hashing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ hash(w::WeakRef, h::UInt) = hash(w.value, h)
2020

2121
## hashing general objects ##
2222

23-
hash(@nospecialize(x), h::UInt) = hash_uint(3h - object_id(x))
23+
hash(@nospecialize(x), h::UInt) = hash_uint(3h - objectid(x))
2424

2525
## core data hashing functions ##
2626

base/irrationals.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ isinteger(::AbstractIrrational) = false
114114
iszero(::AbstractIrrational) = false
115115
isone(::AbstractIrrational) = false
116116

117-
hash(x::Irrational, h::UInt) = 3*object_id(x) - h
117+
hash(x::Irrational, h::UInt) = 3*objectid(x) - h
118118

119119
widen(::Type{T}) where {T<:Irrational} = T
120120

base/namedtuple.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ isequal(a::NamedTuple, b::NamedTuple) = false
101101
_nt_names(::NamedTuple{names}) where {names} = names
102102
_nt_names(::Type{T}) where {names,T<:NamedTuple{names}} = names
103103

104-
hash(x::NamedTuple, h::UInt) = xor(object_id(_nt_names(x)), hash(Tuple(x), h))
104+
hash(x::NamedTuple, h::UInt) = xor(objectid(_nt_names(x)), hash(Tuple(x), h))
105105

106106
isless(a::NamedTuple{n}, b::NamedTuple{n}) where {n} = isless(Tuple(a), Tuple(b))
107107
# TODO: case where one argument's names are a prefix of the other's

base/reflection.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ macro isdefined(s::Symbol)
216216
end
217217

218218
"""
219-
object_id(x)
219+
objectid(x)
220220
221-
Get a hash value for `x` based on object identity. `object_id(x)==object_id(y)` if `x === y`.
221+
Get a hash value for `x` based on object identity. `objectid(x)==objectid(y)` if `x === y`.
222222
"""
223-
object_id(@nospecialize(x)) = ccall(:jl_object_id, UInt, (Any,), x)
223+
objectid(@nospecialize(x)) = ccall(:jl_object_id, UInt, (Any,), x)
224224

225225
struct DataTypeLayout
226226
nfields::UInt32

doc/src/base/base.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Core.typeassert
114114
Core.typeof
115115
Core.tuple
116116
Base.ntuple
117-
Base.object_id
117+
Base.objectid
118118
Base.hash
119119
Base.finalizer
120120
Base.finalize

doc/src/manual/modules.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ are a trickier case. In the common case where the keys are numbers, strings, sy
299299
`Expr`, or compositions of these types (via arrays, tuples, sets, pairs, etc.) they are safe to
300300
precompile. However, for a few other key types, such as `Function` or `DataType` and generic
301301
user-defined types where you haven't defined a `hash` method, the fallback `hash` method depends
302-
on the memory address of the object (via its `object_id`) and hence may change from run to run.
302+
on the memory address of the object (via its `objectid`) and hence may change from run to run.
303303
If you have one of these key types, or if you aren't sure, to be safe you can initialize this
304304
dictionary from within your `__init__` function. Alternatively, you can use the `ObjectIdDict`
305305
dictionary type, which is specially handled by precompilation so that it is safe to initialize
@@ -328,7 +328,7 @@ Other known potential failure scenarios include:
328328
at the end of compilation. All subsequent usages of this incrementally compiled module will start
329329
from that same counter value.
330330

331-
Note that `object_id` (which works by hashing the memory pointer) has similar issues (see notes
331+
Note that `objectid` (which works by hashing the memory pointer) has similar issues (see notes
332332
on `Dict` usage below).
333333

334334
One alternative is to use a macro to capture [`@__MODULE__`](@ref) and store it alone with the current `counter` value,

stdlib/Distributed/src/clusterserialize.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mutable struct ClusterSerializer{I<:IO} <: AbstractSerializer
1414

1515
pid::Int # Worker we are connected to.
1616
tn_obj_sent::Set{UInt64} # TypeName objects sent
17-
glbs_sent::Dict{UInt64, UInt64} # (key,value) -> (object_id, hash_value)
17+
glbs_sent::Dict{UInt64, UInt64} # (key,value) -> (objectid, hash_value)
1818
glbs_in_tnobj::Dict{UInt64, Vector{Symbol}} # Track globals referenced in
1919
# anonymous functions.
2020
anonfunc_id::UInt64
@@ -116,7 +116,7 @@ function serialize(s::ClusterSerializer, g::GlobalRef)
116116
end
117117

118118
# Send/resend a global object if
119-
# a) has not been sent previously, i.e., we are seeing this object_id for the first time, or,
119+
# a) has not been sent previously, i.e., we are seeing this objectid for the first time, or,
120120
# b) hash value has changed or
121121
# c) is a bits type
122122
function syms_2b_sent(s::ClusterSerializer, identifier)
@@ -128,7 +128,7 @@ function syms_2b_sent(s::ClusterSerializer, identifier)
128128
if isbits(v)
129129
push!(lst, sym)
130130
else
131-
oid = object_id(v)
131+
oid = objectid(v)
132132
if haskey(s.glbs_sent, oid)
133133
# We have sent this object before, see if it has changed.
134134
s.glbs_sent[oid] != hash(sym, hash(v)) && push!(lst, sym)
@@ -143,7 +143,7 @@ end
143143
function serialize_global_from_main(s::ClusterSerializer, sym)
144144
v = getfield(Main, sym)
145145

146-
oid = object_id(v)
146+
oid = objectid(v)
147147
record_v = true
148148
if isbits(v)
149149
record_v = false
@@ -179,7 +179,7 @@ function deserialize_global_from_main(s::ClusterSerializer, sym)
179179
end
180180

181181
function delete_global_tracker(s::ClusterSerializer, v)
182-
oid = object_id(v)
182+
oid = objectid(v)
183183
if haskey(s.glbs_sent, oid)
184184
delete!(s.glbs_sent, oid)
185185
end

stdlib/Distributed/test/distributed_exec.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,8 +1161,8 @@ v6 = FooModEverywhere
11611161
Base.Serializer.serialize_type(s, TestSerCnt)
11621162
serialize(s, t.v)
11631163
global testsercnt_d
1164-
cnt = get!(testsercnt_d, object_id(t), 0)
1165-
testsercnt_d[object_id(t)] = cnt+1
1164+
cnt = get!(testsercnt_d, objectid(t), 0)
1165+
testsercnt_d[objectid(t)] = cnt+1
11661166
end
11671167

11681168
Base.deserialize(s::AbstractSerializer, ::Type{TestSerCnt}) = TestSerCnt(deserialize(s))
@@ -1174,22 +1174,22 @@ for i in 1:5
11741174
remotecall_fetch(()->tsc, id_other)
11751175
end
11761176
# should have been serialized only once
1177-
@test testsercnt_d[object_id(tsc)] == 1
1177+
@test testsercnt_d[objectid(tsc)] == 1
11781178

11791179
# hash values are changed
11801180
n=5
1181-
testsercnt_d[object_id(tsc)] = 0
1181+
testsercnt_d[objectid(tsc)] = 0
11821182
for i in 1:n
11831183
tsc.v[i] = i
11841184
remotecall_fetch(()->tsc, id_other)
11851185
end
11861186
# should have been serialized as many times as the loop
1187-
@test testsercnt_d[object_id(tsc)] == n
1187+
@test testsercnt_d[objectid(tsc)] == n
11881188

11891189
# Multiple references in a closure should be serialized only once.
11901190
global mrefs = TestSerCnt(fill(1.,10))
11911191
@test remotecall_fetch(()->(mrefs.v, 2*mrefs.v, 3*mrefs.v), id_other) == (fill(1.,10), fill(2.,10), fill(3.,10))
1192-
@test testsercnt_d[object_id(mrefs)] == 1
1192+
@test testsercnt_d[objectid(mrefs)] == 1
11931193

11941194

11951195
# nested anon functions
@@ -1239,9 +1239,9 @@ global ids_func = ()->ids_cleanup
12391239
clust_ser = (Distributed.worker_from_id(id_other)).w_serializer
12401240
@test remotecall_fetch(ids_func, id_other) == ids_cleanup
12411241

1242-
@test haskey(clust_ser.glbs_sent, object_id(ids_cleanup))
1242+
@test haskey(clust_ser.glbs_sent, objectid(ids_cleanup))
12431243
finalize(ids_cleanup)
1244-
@test !haskey(clust_ser.glbs_sent, object_id(ids_cleanup))
1244+
@test !haskey(clust_ser.glbs_sent, objectid(ids_cleanup))
12451245

12461246
# TODO Add test for cleanup from `clust_ser.glbs_in_tnobj`
12471247

stdlib/SharedArrays/test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ finalize(d)
284284
let
285285
aorig = a1 = SharedArray{Float64}((3, 3))
286286
a1 = remotecall_fetch(fill!, id_other, a1, 1.0)
287-
@test object_id(aorig) == object_id(a1)
287+
@test objectid(aorig) == objectid(a1)
288288
id = a1.id
289289
aorig = nothing
290290
a1 = remotecall_fetch(fill!, id_other, a1, 1.0)

test/asyncmap.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
using Random
44

55
# Test asyncmap
6-
@test allunique(asyncmap(x->(sleep(1.0);object_id(current_task())), 1:10))
6+
@test allunique(asyncmap(x->(sleep(1.0);objectid(current_task())), 1:10))
77

88
# num tasks
9-
@test length(unique(asyncmap(x->(yield();object_id(current_task())), 1:20; ntasks=5))) == 5
9+
@test length(unique(asyncmap(x->(yield();objectid(current_task())), 1:20; ntasks=5))) == 5
1010

1111
# default num tasks
12-
@test length(unique(asyncmap(x->(yield();object_id(current_task())), 1:200))) == 100
12+
@test length(unique(asyncmap(x->(yield();objectid(current_task())), 1:200))) == 100
1313

1414
# ntasks as a function
1515
let nt=0
@@ -18,7 +18,7 @@ let nt=0
1818
# nt_func() will be called initally once and then for every
1919
# iteration
2020
end
21-
@test length(unique(asyncmap(x->(yield();object_id(current_task())), 1:200; ntasks=nt_func))) == 7
21+
@test length(unique(asyncmap(x->(yield();objectid(current_task())), 1:200; ntasks=nt_func))) == 7
2222

2323
# batch mode tests
2424
let ctr=0

test/core.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3477,7 +3477,7 @@ const const_array_int2 = Array{Int}
34773477
test_eq_array_int() = ===(const_array_int1, const_array_int2)
34783478
@test test_eq_array_int()
34793479

3480-
# object_id of haspadding field
3480+
# objectid of haspadding field
34813481
struct HasPadding
34823482
x::Bool
34833483
y::Int
@@ -3489,7 +3489,7 @@ let hashaspadding = Ref(HasHasPadding(HasPadding(true,1))),
34893489
hashaspadding2 = Ref(HasHasPadding(HasPadding(true,1)))
34903490
unsafe_store!(convert(Ptr{UInt8},pointer_from_objref(hashaspadding)), 0x12, 2)
34913491
unsafe_store!(convert(Ptr{UInt8},pointer_from_objref(hashaspadding2)), 0x21, 2)
3492-
@test object_id(hashaspadding[]) == object_id(hashaspadding2[])
3492+
@test objectid(hashaspadding[]) == objectid(hashaspadding2[])
34933493
end
34943494

34953495
# issue #12517
@@ -3800,7 +3800,7 @@ let
38003800
end
38013801

38023802
# issue #14564
3803-
@test isa(object_id(Tuple.name.cache), Integer)
3803+
@test isa(objectid(Tuple.name.cache), Integer)
38043804

38053805
# issue #14691
38063806
mutable struct T14691; a::UInt; end
@@ -5636,7 +5636,7 @@ let x5 = UnionField5(nothing, Int8(3))
56365636
@test x5 == x5
56375637
@test x5 === x5copy
56385638
@test x5 == x5copy
5639-
@test object_id(x5) === object_id(x5copy)
5639+
@test objectid(x5) === objectid(x5copy)
56405640
@test hash(x5) === hash(x5copy)
56415641
end
56425642

@@ -5667,7 +5667,7 @@ let
56675667
@test b === b2 === b3
56685668
@test compare(b, b2)
56695669
@test compare(b, b3)
5670-
@test object_id(b) === object_id(b2) == object_id(b3)
5670+
@test objectid(b) === objectid(b2) == objectid(b3)
56715671
@test b.x === Int8(91)
56725672
@test b.z === Int8(23)
56735673
@test b.y === A23367((Int8(1), Int8(2), Int8(3), Int8(4), Int8(5), Int8(6), Int8(7)))

test/hashing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ end
207207
# issue #20744
208208
@test hash(:c, hash(:b, hash(:a))) != hash(:a, hash(:b, hash(:c)))
209209

210-
# issue #5849, object_id of types
210+
# issue #5849, objectid of types
211211
@test Vector === (Array{T,1} where T)
212212
@test (Pair{A,B} where A where B) !== (Pair{A,B} where B where A)
213213
let vals_expr = :(Any[Vector, (Array{T,1} where T), 1, 2, Union{Int, String}, Union{String, Int},
@@ -219,6 +219,6 @@ let vals_expr = :(Any[Vector, (Array{T,1} where T), 1, 2, Union{Int, String}, Un
219219
vals_b = eval(vals_expr)
220220
for (i, a) in enumerate(vals_a), (j, b) in enumerate(vals_b)
221221
@test i != j || (a === b)
222-
@test (a === b) == (object_id(a) == object_id(b))
222+
@test (a === b) == (objectid(a) == objectid(b))
223223
end
224224
end

test/strings/basic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using Random
1818
@test codegen_egal_of_strings(string("ab", 'c'), "abc") === (true, false)
1919
let strs = ["", "a", "a b c", "до свидания"]
2020
for x in strs, y in strs
21-
@test (x === y) == (object_id(x) == object_id(y))
21+
@test (x === y) == (objectid(x) == objectid(y))
2222
end
2323
end
2424
end

0 commit comments

Comments
 (0)