PERF: Styler render improvement by limiting .join() by attack68 · Pull Request #39952 · pandas-dev/pandas (original) (raw)

Currently
<th> only have attributes when there is a row or column span.
<td> never have attributes currently.
So there is no need for repititive join() operations, especially inside the jinja2 template. Could be preconfigured outside.

We can get around 10-15% better render times.

[ 75.00%] ··· io.style.RenderApply.time_render                                                                                                           ok
[ 75.00%] ··· ====== ============ ============
              --                rows          
              ------ -------------------------
               cols       12          120     
              ====== ============ ============
                12    11.6±0.5ms   77.0±0.5ms 
                24    29.2±0.5ms    144±1ms   
                36    43.7±0.9ms    209±2ms   
              ====== ============ ============

versus master

[100.00%] ··· io.style.RenderApply.time_render                                                                                                           ok
[100.00%] ··· ====== ============ ==========
              --               rows         
              ------ -----------------------
               cols       12         120    
              ====== ============ ==========
                12    12.9±0.4ms   89.8±4ms 
                24    31.4±0.9ms   166±2ms  
                36     46.5±2ms    250±40ms 
              ====== ============ ==========