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/2004-November/049793.html below:

[Python-Dev] Re: weakref gc semantics

[Python-Dev] Re: weakref gc semantics [Python-Dev] Re: weakref gc semanticsTim Peters tim.peters at gmail.com
Fri Nov 5 16:05:23 CET 2004
[Greg Ewing]
>> Maybe the callback shouldn't be passed the weakref object?
>> I don't see what good that does anyway, since the weakref
>> is just an empty shell by then, isn't it?

[Jim Fulton]
> No.  It can still be used as a key. It still has it's original
> hash value and will compare equal to other weakrefs to the same
> original object. Weak-key dictionaries depend on this.

Right.

> In addition, as Tim points out, it could be a weakref-subclass instance
> and could have additional useful data.

Adn weak-value dictionaries depend on that; from weakref.py:

class KeyedRef(ref):
    """Specialized reference that includes a key corresponding to the value.

    This is used in the WeakValueDictionary to avoid having to create
    a function object for each key stored in the mapping.  A shared
    callback object can use the 'key' attribute of a KeyedRef instead
    of getting a reference to the key from an enclosing scope.

    """
    ...
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