Is there an equivalent to Python's `id()` function in GDScript?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Demindiro

Is there any way to get the “identity”/reference/pointer to a Dictionary/Array akin to Python’s id() function?

I would like to use it for debugging and for ensuring two arrays/dictionaries are not the same object.

I tried using weakref (e.g. weakref({})) but it causes an error saying ‘The passed argument’s type (Dictionary) doesn’t match the function’s expected argument type (Object)’.

I haven’t really looked into this, but maybe you can use an RID? Resources have RIDs, so Arrays or Dictionaries may have RIDs, too.

Ertain | 2020-10-30 18:02