In what order are multiple finalizers of one object run?

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.

They work just fine as keys. It’s just not recommended to iterate over a Dict. It may be possible to disable gc collection of the keys while doing iteration however.

Because it would violate causality?

So the only “problem” is the iteration over the keys of a WeakKeyDict. Thanks for clarifying. (In this case I think the “See Dict for further help.” part in the documentation of WeakKeyDict is misleading.)