Le Tue, 19 May 2009 11:36:17 +0200, spir <denis.s...@free.fr> s'exprima ainsi:
> Hello, > > This is a follow the post on performance issues. > Using a profiler, I realized that inside error message creation, most of > the time was spent in a tool func used to clean up source text output. The > issue is that when the source text holds control chars such as \n, then the > error message is hardly readible. MY solution is to replace such chars with > their repr(): > > def _cleanRepr(text): > ''' text with control chars replaced by repr() equivalent ''' > result = "" > for char in text: > n = ord(char) > if (n < 32) or (n > 126 and n < 160): > char = repr(char)[1:-1] > result += char > return result Changed to: def _cleanRepr(text): ''' text with control chars replaced by repr() equivalent ''' chars = [] for char in text: n = ord(char) if (n < 32) or (n > 126 and n < 160): char = repr(char)[1:-1] chars.append(char) return ''.join(chars) But what else can I do? Denis ------ la vita e estrany _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor