Cast list of objects to list of strings

jay graves jaywgraves at
Tue Jun 3 15:49:52 CEST 2008

On Jun 2, 8:36 pm, "Gabriel Genellina" <gagsl-... at> wrote:
> Still nitpicking: using a generator expression in this case has no
> advantage. The first thing that str.join does is to create a list out of
> its argument (unless it is already a list or a tuple). In fact, a list
> comprehension is faster here.

Really!  I stand corrected.

I'm not a C programmer but I peeked at the source.  I see that it
makes a pass to calculate the total size and then another pass to
catenate the items, which makes sense from a memory allocation

To compare and contrast, I looked up the 'sum' built in and saw that
it used the iterator protocol, (PyObject_GetIter).  I assume that the
other similar functions (min,max, etc) would do the same.

Thanks for setting me straight.

More information about the Python-list mailing list