Let's say I have a set of myset
user objects that can be equal, although their references are different ( a == b and a is not b
). Now, if I add(a)
to a set, Python correctly assumes that a in myset and b in myset
, although there is only a len(myset) == 1
object in the set.
It is clear. But is it now possible to extract the value of a
from the set using only b
? Suppose the objects are mutable, and I want to change them, forgetting about the direct link to a
. In other words, I am looking for the operation myset[b]
, which will definitely return the member a
for the set.
It seems to me that the set
type cannot do this (faster than repeating through all its members). If so, is there at least effective work?
source share