Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

> If space is not an issue, the list comprehension may be fastest.

I think there is still a misunderstanding here.  The generator variant does not 
save space.  It uses slightly *more* space than the list variant.

The list_ass_slice()¹ function runs PySequence_Fast² on its input.  If the 
input is already a list or tuple, it is returned immediately.  If not, the 
iterator is run to exhaustion and a new list is built.  Either way, when the 
actual update occurs, the source will be a list or tuple.

¹ https://github.com/rhettinger/cpython/blob/master/Objects/listobject.c#L597
² https://github.com/rhettinger/cpython/blob/master/Objects/abstract.c#L2014

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41774>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to