[WIP] bpo-36560: _abc now uses weakref.WeakSet type#12743
[WIP] bpo-36560: _abc now uses weakref.WeakSet type#12743vstinner wants to merge 1 commit intopython:masterfrom vstinner:_abc_weakref
Conversation
|
@ilevkivskyi: I wrote this PR to try to debug https://bugs.python.org/issue36560 That's also why I had to fix regrtest when _abc is not built: https://bugs.python.org/issue36565 Honestly, I'm not sure that using weakref.WeakSet type provides any benefit compared to the current implementation, but I wanted to show you the code just in case :-) I'm also using this PR to debug https://bugs.python.org/issue36560 even if modifying Modules/Setup to disable the compilation of the _abc module should have the same effect: Lib/_py_abc.py already uses weakref.WeakSet, so it should provide the same behavior than this PR. |
The C accelerator _abc now uses the weakref.WeakSet type rather than the set type holding weak references. Changes: * _abc._get_dump() now returns lists rather than sets. * subclasscheck_check_registry() now longer holds a second strong reference to 'rkey' to call PyObject_IsSubclass(): the 'registry' list already holds a strong reference.
Moreover, I didn't measure the performance impact yet. Lib/_weakset.py is implemented fully in pure-Python: it might be slower than your efficient implementation written in C. |
|
Yes, |
|
Please keep this PR open until https://bugs.python.org/issue36560 is closed. |
|
This PR isn't really needed to debug https://bugs.python.org/issue36560 : modify Modules/Setup to no longer compile "_abc" does basically the same thing than this PR. |
The C accelerator _abc now uses the weakref.WeakSet type rather than
the set type holding weak references.
Changes:
reference to 'rkey' to call PyObject_IsSubclass(): the 'registry'
list already holds a strong reference.
https://bugs.python.org/issue36560