[issue1061] ABC caches should use weak refs

Georg Brandl report at bugs.python.org
Thu Aug 30 21:02:39 CEST 2007


Georg Brandl added the comment:

Guido van Rossum schrieb:
> Guido van Rossum added the comment:
> 
> On 8/30/07, Thomas Wouters <report at bugs.python.org> wrote:
>>
>> Thomas Wouters added the comment:
>>
>> Here's a working version of that idea, with a WeakSet implementation I
>> had lying around (but never really used.) It seems to work, and fixes
>> the refcount issues, but the WeakSet could do with some extra tests ;-)
> 
> I was torturing the WeakSet implementation, but didn't get very far:
> 
> Python 3.0x (py3k, Aug 30 2007, 09:27:35)
> [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from weakref import WeakSet as WS
> [40407 refs]
>>>> a = WS([1, 2, 3])
> Fatal Python error: Cannot recover from stack overflow.
> Aborted

The update() method can not be implemented in terms of converting the
argument to a WeakSet, since that leads to infinite recursion on creation
(as to why you get this fatal error, not a RuntimeError, no idea).

Also, the fact that the operator-versions of set operations only support
other sets as their second operands, while the method-versions support any
iterable, is not preserved.

Georg

----------
nosy: +georg.brandl

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1061>
__________________________________


More information about the Python-bugs-list mailing list