On 1/20/2016 4:08 PM, Brett Cannon wrote:


On Wed, 20 Jan 2016 at 15:46 Victor Stinner <victor.stin...@gmail.com <mailto:victor.stin...@gmail.com>> wrote:

    Hi,

    2016-01-20 22:18 GMT+01:00 Glenn Linderman <v+pyt...@g.nevcal.com
    <mailto:v%2bpyt...@g.nevcal.com>>:
    > On 1/20/2016 12:50 PM, Brett Cannon wrote:
    >>
    >> 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.

    I think that Yury found a bug in FAT Python. I didn't test the case
    when the builtins dictionary is replaced after the definition of the
    function. To be more concrete: when a function is executed in a
    different namespace using exec(code, namespace). That's why I like the
    PEP process, it helps to find all issues before going too far :-)

    I like the idea of global counter for dictionary versions. It means
    that the dictionary constructor increases this counter instead of
    always starting to 0.

    FYI a fat.GuardDict keeps a strong reference to the dictionary. For
    some guards, I hesitated to store the object identifier and/or using a
    weak reference. An object identifier is not reliable because the
    object can be destroyed and a new object, completly different, or of
    the same type, can get the same identifier.

    > But would invalidate everything, instead of just a fraction of
    things, on
    > every update to anything that is monitored...

    I don't understand this point.


I think Glenn was assuming we had a single, global version # that all dicts shared *without* having a per-dict version ID. The key thing here is that we have a global counter that tracks the number of mutations for *all* dictionaries but whose value we store as a *per-dictionary* value. That ends up making the version ID inherently both a token representing the state of any dict but also the uniqueness of the dict since no two dictionaries will ever have the same version ID.

This would work. You were correct about my assumptions.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to