[issue10516] Add list.clear() and list.copy()

Eli Bendersky report at bugs.python.org
Sat Nov 27 11:37:45 CET 2010


Eli Bendersky <eliben at gmail.com> added the comment:

>
> Hi, I'm also looking at listobject.c also... if we want list.clear() to
> behave exactly like del list[], we may be able to just call list_ass_slice
> on the list. Similarly for list.copy which should behave like a=l[:]
>

Note that when executed to do 'del lst[:]' (i.e. with argument v set to 0
and ilow/ihigh to the maximal range of the list), list_ass_slice will just
call list_clear anyway, which is a cue that this indeed is the right way to
do it, despite the strange comment I mentioned in my message above.

----------
Added file: http://bugs.python.org/file19834/unnamed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10516>
_______________________________________
-------------- next part --------------
<div dir="ltr"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Hi, I&#39;m also looking at listobject.c also... if we want list.clear() to behave exactly like del list[], we may be able to just call list_ass_slice on the list. Similarly for list.copy which should behave like a=l[:]<br>

</blockquote></div><br>Note that when executed to do &#39;del lst[:]&#39; (i.e. with argument v set to 0 and ilow/ihigh to the maximal range of the list), list_ass_slice will just call list_clear anyway, which is a cue that this indeed is the right way to do it, despite the strange comment I mentioned in my message above.<br>

<br></div>


More information about the Python-bugs-list mailing list