##// END OF EJS Templates
fix n^2 performance issue in coalesce_streams preprocessor...
MinRK -
Show More
@@ -40,6 +40,7 b' def cell_preprocessor(function):'
40 40 return nb, resources
41 41 return wrappedfunc
42 42
43 cr_pat = re.compile(r'.*\r(?=[^\n])')
43 44
44 45 @cell_preprocessor
45 46 def coalesce_streams(cell, resources, index):
@@ -64,7 +65,6 b' def coalesce_streams(cell, resources, index):'
64 65
65 66 last = outputs[0]
66 67 new_outputs = [last]
67
68 68 for output in outputs[1:]:
69 69 if (output.output_type == 'stream' and
70 70 last.output_type == 'stream' and
@@ -72,12 +72,14 b' def coalesce_streams(cell, resources, index):'
72 72 ):
73 73 last.text += output.text
74 74
75 # Respect \r characters.
76 cr_pat = re.compile(r'.*\r(?=[^\n])')
77 last.text = cr_pat.sub('', last.text)
78 75 else:
79 76 new_outputs.append(output)
80 77 last = output
81 78
79 # process \r characters
80 for output in new_outputs:
81 if output.output_type == 'stream':
82 output.text = cr_pat.sub('', output.text)
83
82 84 cell.outputs = new_outputs
83 85 return cell, resources
General Comments 0
You need to be logged in to leave comments. Login now