[Python-Dev] PEP 509: Add a private version to dict (original) (raw)

Yury Selivanov yselivanov.ml at gmail.com
Wed Jan 20 15:27:12 EST 2016


On 2016-01-20 2:45 PM, Glenn Linderman wrote:

For the reuse case, can't you simply keep the maversion "live" in dict items on the free list, rather than starting over at (presumably) 0 ? Then if the dict is reused, it bumps the maversion, and the fallback code goes on with (presumably) relocating the original dict (oops, it's gone), and dealing with the fallout.

Not all dicts are created from a freelist, and not all dicts go to the freelist when they are GCed.

You still can have this situation:

Then you can use the regular dict id as the globally unique dict id? And only need the one uint64, rather than a separately allocated extra pair of uint64?

In my design only namespace dicts will have a non-NULL ma_extra, which means that only a fraction of dicts will actually have a separated pair of uint64s.

I think that we should either use one global ma_version (as Maciej suggested) or ma_extra, as it gives more flexibility for us to extend dicts in the future.

A global (shared between all dicts) unit64 ma_version is actually quite reliable -- if a program does 1,000,000 dict modifications per second, it would take it 600,000 years till wrap-around.

Yury



More information about the Python-Dev mailing list