On Oct 31, 9:12 pm, Dave Angel <d...@davea.name> wrote: > I would claim that a well-written (in C) translate function, without > using the delete option, should be much quicker than any python loop, > even if it does copy the data.
Are you arguing with me? I was agreeing with you, I thought, that translate would be faster than a regex. I also pointed out that the delete function was available as , but OTOH, that might be a little slow because I think it does the deletion before the translate. I think I'd just do something like this: >>> transtab = ''.join(' ' if 32 <= x <= 126 else chr(x) for x in range(256)) >>> 'abc\x05\def\x0aghi'.translate(transtab).replace(' ', '') '\x05\n' Regards, Pat -- http://mail.python.org/mailman/listinfo/python-list