It seems that WeakKeyDict contains finalized elements? shows that currently WeakKeyDict should not (cannot?) be used with objects, which already have finalizers registered. This excludes for example the usage of BigFloat
or BigInt
as keys in a WeakKeyDict. This is probably due to the fact, that the finalizer, which is responsible for deleting an object from the dictionary, is not run first.
Why are finalizers for one object not run all “at the same time”? Is the order in which finalizers are run documented somewhere? Can it be made LIFO?
Sorry if I did not use the proper terminology, but I am not familar with gc internals.