PERF: make Styler default formatter arguments statics instead of repeated dynamic by attack68 · Pull Request #40425 · pandas-dev/pandas (original) (raw)
This PR is a minor fix/improvement to a recent PR which deprecated set_na_rep
and set_precision
. #40134
For a dataframe with 100,000 floats the current Styler default formatter will make 100,000 get_option
lookups for the pandas precision.
Doing this calculation once prevents all these lookups and saves just over 10% render time for larger tables.
rows THIS PR
------ -------------------------
cols 12 120
====== ============ ============
12 11.8±0.2ms 40.8±0.8ms
24 22.5±0.3ms 69.2±2ms
36 32.3±0.6ms 96.9±1ms
====== ============ ============
rows MASTER
------ -------------------------
cols 12 120
====== ============ ============
12 12.9±0.4ms 43.4±1ms
24 22.3±0.1ms 75.2±0.7ms
36 32.3±0.3ms 105±0.5ms
====== ============ ============