<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 8, 2016 at 11:44 PM Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 9 January 2016 at 16:03, Serhiy Storchaka <<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>> wrote:<br>
> On 08.01.16 23:27, Victor Stinner wrote:<br>
>><br>
>> Add a new read-only ``__version__`` property to ``dict`` and<br>
>> ``collections.UserDict`` types, incremented at each change.<br>
><br>
><br>
> This may be not the best name for a property. Many modules already have the<br>
> __version__ attribute, this may make a confusion.<br>
<br>
The equivalent API for the global ABC object graph is<br>
abc.get_cache_token:<br>
<a href="https://docs.python.org/3/library/abc.html#abc.get_cache_token" rel="noreferrer" target="_blank">https://docs.python.org/3/library/abc.html#abc.get_cache_token</a><br>
<br>
One of the reasons we chose that name is that even though it's a<br>
number, the only operation with semantic significance is equality<br>
testing, with the intended use case being cache invalidation when the<br>
token changes value.<br>
<br>
If we followed the same reasoning for Victor's proposal, then a<br>
suitable attribute name would be "__cache_token__".<br></blockquote><div><br></div><div>+1 for consistency.  for most imaginable uses the actual value and type of the value doesn't matter, you just care if it is different than the value you recorded earlier. How the token/version gets mutated should be up to the implementation within defined parameters such as "the same value is never re-used twice for the lifetime of a process" (which pretty much guarantees some form of unsigned 64-bit counter increment - but an implementation could choose to use 256 bit random numbers for all we really care).  Calling it __version__ implies numeric, but that isn't a requirement.</div><div><br></div><div>we _really_ don't want someone to write code depending upon it being a number and expecting it to change in a given manner so that they do something conditional on math performed on that number rather than a simple == vs !=.</div><div><br></div><div>-gps </div></div></div>