dwave.optimization.model.Symbol.id#
- Symbol.id()#
Return the “identity” of the underlying node.
This identity is unique to the underlying node, rather than the identity of the Python object representing it. Therefore,
symdol.id()
is not the same asid(symbol)
!Examples
>>> from dwave.optimization import Model ... >>> model = Model() >>> a = model.binary() >>> aa, = model.iter_symbols() >>> assert a.id() == aa.id() >>> assert id(a) != id(aa)
While symbols are not hashable, the
.id()
is.>>> model = Model() >>> x = model.integer() >>> seen = {x.id()}
See also
shares_memory()
:a.shares_memory(b)
is equivalent toa.id() == b.id()
.equals()
:a.equals(b)
will returnTrue
ifa.id() == b.id()
. Though the inverse is not necessarily true.