A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-January/151637.html below:

[Python-Dev] PEP 567 v2

[Python-Dev] PEP 567 v2 [Python-Dev] PEP 567 v2Nathaniel Smith njs at pobox.com
Fri Jan 5 18:26:42 EST 2018
On Thu, Jan 4, 2018 at 3:18 PM, Nathaniel Smith <njs at pobox.com> wrote:
> I think the fix is a little bit cumbersome, but straightforward, and
> actually *simplifies* caching.
[...]
> And then the caching in get() becomes:
>
> def get(self):
>     if tstate->current_context != self->last_context:
>         # Update cache
>         self->last_value = tstate->current_context_data->hamt_lookup(self)
>         self->last_context = tstate->current_context
>     return self->last_value

Actually, this trick of using the Context* as the cache validation key
doesn't work :-/. The problem is that the cache doesn't hold a strong
reference to the Context, so there's an ABA problem [1] if the Context
is deallocated, and then later the same memory location gets used for
a new Context object. It could be fixed by using weakref callbacks,
but that's not really simpler than the current counter-based cache
validation logic.

-n

[1] https://en.wikipedia.org/wiki/ABA_problem

-- 
Nathaniel J. Smith -- https://vorpus.org
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4