[Python-Dev] PyWeakref_GetObject() borrows its reference from... whom? (original) (raw)
Xavier Morel catch-all at masklinn.net
Mon Oct 10 07:06:20 EDT 2016
- Previous message (by thread): [Python-Dev] PyWeakref_GetObject() borrows its reference from... whom?
- Next message (by thread): [Python-Dev] PyWeakref_GetObject() borrows its reference from... whom?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2016-10-10, at 11:05 , Devin Jeanpierre <jeanpierreda at gmail.com> wrote: The term "borrowed" is supposed to imply a sensible scope during which you're free to use the object, and weakrefs don't have that (except for what is granted by the GIL), so this does sound wacky. I bet it was for performance.
Especially as it handles both getting an object from a weakref and checking whether the weakref is still alive.
OTOH it could be an enshrined bug, http://bugs.python.org/issue520087 fixed a discrepancy between the doc and the implementation by matching the doc to the implementation (of returning a borrowed ref').
Also of note, pypy developers have been reporting issues with that specific API since ~2010[0][1], and IIRC they have added a PyWeakref_LockObject to cpyext.
[0] http://bugs.python.org/issue8578 [1] http://bugs.python.org/issue16602#msg177272 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20161010/26c0be80/attachment.html>
- Previous message (by thread): [Python-Dev] PyWeakref_GetObject() borrows its reference from... whom?
- Next message (by thread): [Python-Dev] PyWeakref_GetObject() borrows its reference from... whom?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]