[Python-Dev] PyWeakref_GetObject() borrows its reference from... whom?
Guido van Rossum
guido at python.org
Mon Oct 10 12:37:44 EDT 2016
Modified +1: you can't change the behavior of the existing API, but
you can deprecate it and introduce a better one with a different name.
We'll have until Python 4.0 to carry through the deprecation anyways.
And I doubt this is the only C API change needed for happy gil-free
coding...
On Mon, Oct 10, 2016 at 5:29 AM, Fred Drake <fred at fdrake.net> wrote:
> On Mon, Oct 10, 2016 at 4:17 AM, Larry Hastings <larry at hastings.org> wrote:
>> Given that the weakref doesn't have a reference to the object--merely a weak
>> reference, different thing--whose reference is it borrowing?
>
> As others have said, it doesn't really matter who's reference it was;
> just that there was another at the time it was returned. Clearly it
> can't be considered valid once additional Python code might be run.
>
>> FWIW, yes, this is playing merry hell with the Gilectomy. If there are two
>> threads, and one calls PyWeakref_GetObject(obj), and there's only one
>> reference to obj, and the other thread blows it away... now what? It's my
>> contention that this API is simply untenable under the Gilectomy, and that
>> it needs to change to returning a new (strong) reference.
>
> +1 for this change.
>
>
> -Fred
>
> --
> Fred L. Drake, Jr. <fred at fdrake.net>
> "A storm broke loose in my mind." --Albert Einstein
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/guido%40python.org
--
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev
mailing list