[Patches] [ python-Patches-487738 ] weaklist

noreply@sourceforge.net noreply@sourceforge.net
Sat, 01 Dec 2001 17:07:17 -0800


Patches item #487738, was opened at 2001-11-30 17:36
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=487738&group_id=5470

Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Andres Tuells (atuells)
Assigned to: Nobody/Anonymous (nobody)
Summary: weaklist

Initial Comment:
WeakList are list whose entries are referenced weakly. 
When the object is gc it is deleted from the weaklist 
(and from its iterators). To be added to weakref.py

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2001-12-01 17:07

Message:
Logged In: YES 
user_id=21627

Thanks for the patch. I would recommend to publish it as a
separate package first, to get user feedback. I can't see
this as a universally-useful data type, so I'm not sure it
should be added to the standard library.

*If* it is added, a number of corrections must be made to
the code:
- remove removes elements by equality, not identity. I
believe in removeAll, you are looking for identical objects,
not merely equal ones.

- Why is it the right thing to remove elements from the list
if the underlying object dies? doesn't this have undesirable
side effects on indexing, e.g. when the list is being
iterated over?

- In the standard library, I think inheriting from UserList
is deprecated, in favour of inheriting from list.

- It seems that the class creates many unnecessary copies of
lists, e.g. in extend, or setslice.

- The references create cycles involving WeakList. Since the
WeakList refers to ref objects through data, and the ref
objects refer to the list throught the callback, the list
itself will become garbage as long as list elements remain
alive (although GC will detect those cycles). That should be
avoided.

- What is the point of the infinite loop in __getitem__?

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=487738&group_id=5470