I use instances of a custom class (similar to a 2D vector with a bunch of extra stuff among other things) as a dict key.
It uses custom hash and equals magic-methods that basically makes it equal to a tuple with the initialization data.
The data set I'm dealing with is so big that memory (RAM) is a main concern and I need multiple different data structures with the same custom object instances as keys.
I want access to the actual reference of the dict keys.
If I can obtain a dict key from a tuple of the initialization data, I can prevent different custom class instances with the same internal data in different data structures, and instead use the same instance.
Is that possible? And if it is, how?
Example:
dict1 = {}
dict2 = {}
One code segment:
v = MyVect(1,5,"data",True)
dict1[v] = ("important", "data")
Second segment:
(this part has only access to the data that was used to create MyVect but no actual reference.)
keydata_without_reference = (1,5,"data",True)
mykey = dict1.getkeyref(keydata_without_reference) # getkeyref somehow
dict2[mykey] = "some other data"
As result I would save almost half the memory.
This is just to setup the initial data structures that the program uses later.