weak refs in descriptors (http://bugs.python.org/issue17950)
Hello python-dev. I'm working on a patch to remove reference cycles from heap-allocated classes: http://bugs.python.org/issue17950 Part of the patch involves making sure that descriptors in the class dictionary don't contain strong references to the class itself. This is item 2) in the defect description. I have implemented this via weak references and hit no issues at all when running the test suite. But I'd like to ask the oracle if there is anything I may be overlooking with this approach? Any hidden problems we might encounter? K
On Mon, May 13, 2013 at 1:49 PM, Kristján Valur Jónsson <kristjan@ccpgames.com> wrote:
Hello python-dev.
I‘m working on a patch to remove reference cycles from heap-allocated classes: http://bugs.python.org/issue17950
Part of the patch involves making sure that descriptors in the class dictionary don’t contain strong references to the class itself.
This is item 2) in the defect description.
I have implemented this via weak references and hit no issues at all when running the test suite.
But I’d like to ask the oracle if there is anything I may be overlooking with this approach? Any hidden problems we might encounter?
K
Hi Kristjan The strong reference there is a feature. Descriptors keep the class alive if somehow the class disappears and the descriptor itself does not. Please don't change language semantics (yes, this is a change in semantics), just because the test suite passes - I can assure you there are people doing convoluted stuff that expect this to work. Cheers, fijal
On 13 May 2013 10:20, Maciej Fijalkowski <fijall@gmail.com> wrote:
On Mon, May 13, 2013 at 1:49 PM, Kristján Valur Jónsson <kristjan@ccpgames.com> wrote:
Hello python-dev.
I‘m working on a patch to remove reference cycles from heap-allocated classes: http://bugs.python.org/issue17950
Part of the patch involves making sure that descriptors in the class dictionary don’t contain strong references to the class itself.
This is item 2) in the defect description.
I have implemented this via weak references and hit no issues at all when running the test suite.
But I’d like to ask the oracle if there is anything I may be overlooking with this approach? Any hidden problems we might encounter?
K
Hi Kristjan
The strong reference there is a feature. Descriptors keep the class alive if somehow the class disappears and the descriptor itself does not. Please don't change language semantics (yes, this is a change in semantics), just because the test suite passes - I can assure you there are people doing convoluted stuff that expect this to work.
+1 for it being an expected behavior. So I think it would be a nice thing to write a test that breaks under this condition js -><-
Cheers, fijal _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/jsbueno%40python.org.br
On 5/13/2013 9:20 AM, Maciej Fijalkowski wrote:
The strong reference there is a feature. Descriptors keep the class alive if somehow the class disappears and the descriptor itself does
Is this feature stated or implied in the reference manual? 3.3.2.1. Implementing Descriptors 3.3.2.2. Invoking Descriptors ??? or is it an implementation detail that people have come to rely on?
On Mon, 13 May 2013 13:21:17 -0400 Terry Jan Reedy <tjreedy@udel.edu> wrote:
On 5/13/2013 9:20 AM, Maciej Fijalkowski wrote:
The strong reference there is a feature. Descriptors keep the class alive if somehow the class disappears and the descriptor itself does
Is this feature stated or implied in the reference manual? 3.3.2.1. Implementing Descriptors 3.3.2.2. Invoking Descriptors ??? or is it an implementation detail that people have come to rely on?
Any reference that is not documentedly weak is strong by definition; this is Python's basic semantics, there's no need to ask about documentation pointers. The only question is whether some people rely on this particular one. Regards Antoine.
participants (5)
-
Antoine Pitrou
-
Joao S. O. Bueno
-
Kristján Valur Jónsson
-
Maciej Fijalkowski
-
Terry Jan Reedy