[Python-Dev] PEP 509: Add a private version to dict

Victor Stinner victor.stinner at gmail.com
Thu Jan 21 03:34:07 EST 2016


2016-01-21 6:08 GMT+01:00 Yury Selivanov <yselivanov.ml at gmail.com>:
> Yeah, I think that's what we agreed on:
> https://mail.python.org/pipermail/python-dev/2016-January/142837.html
>
> The only advantage of ma_extra pointer is that it allows to add more stuff
> to dicts in the future.

I don't agree on ma_extra since I don't understand it :-) What is the
advantage compared to a simple integer? If it's a pointer, it requires
to dereference the pointer? You say that it can be NULL, does it mean
that we also have to first test if the pointer is NULL. Does it mean
that we have to allocate a second memory block to store a version tag
object? When do you create a version tag or not?

Note: The PEP 509 proposes to use 64-bit integer for the version on
32-bit systems to avoid integer overflow after a few seconds. I first
proposed to use the size_t type (which has the size of a pointer) but
it doesn't work.

I tried to fix FAT Python to handle your use case: function defined in
a namespace and run in a different namespace (especially for the
builtin dictionary). It looks like I don't need the discussion change
to use a global version, FAT Python guards have a different design
than your cache.

But if a global counter doesn't make the slow more complex and opens
new kinds of optimization, I agree to change my PEP 509.

Victor


More information about the Python-Dev mailing list