list.clear() missing?!?

Peter Hansen peter at engcorp.com
Wed Apr 12 13:28:59 EDT 2006


John Salerno wrote:
> Steven Bethard wrote:
>>I think these are all good reasons for adding a clear method, but being 
>>that it has been so hotly contended in the past, I don't think it will 
>>get added without a PEP.  Anyone out there willing to take out the best 
>>examples from this thread and turn it into a PEP?
> 
> What are the usual arguments against adding it?

I think one is that it's very rare to need it.  Most of the time, just 
rebinding the name to a new empty list is easier, and possibly faster. 
The main problem with that approach is that in multithreaded code that 
can be a source of subtle bugs.  On the other hand, most things can be a 
source of subtle bugs in multithreaded code, so maybe that's not a good 
reason to add clear().

Saving us time answering the question repeatedly (and trying to justify 
the current state of affairs) might be justification enough...

-Peter




More information about the Python-list mailing list