itertools.flatten()? and copying generators/iterators.

Peter Otten __peter__ at web.de
Tue Oct 28 07:58:01 EST 2003


Francis Avila wrote:

> try: seq+'' seems more expensive.  Is it just to handle the case where
> someone makes a string-alike that doesn't derive from str? (Actually, I
> guess that's about all pre-2.2 code.)
> 
> Is it expensive enough to even matter?
> --
> Francis Avila

I you think that the concatenation is costly, as I did when I read your
remark - it's not:

>>> smartSnakes = "don't rattle"
>>> smartSnakes is (smartSnakes + "")
True

Peter




More information about the Python-list mailing list