En Tue, 27 May 2008 14:43:52 -0300, Ian Kelly <[EMAIL PROTECTED]>
escribió:
It sounds like the wasteful list creation is the biggest objection to
using a list comprehension. I'm curious what people think of this
alternative, which avoids populating the list by using a generator
expression instead (apart from the fact that this is still quadratic,
which I'm aware of).
def compress(s):
new = []
filter(None, (new.append(c) for c in s if c not in new))
return ''.join(new)
filter returns a newly created list, so this code is as wasteful as a list
comprehension (and harder to read).
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list