Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PERF: make Styler default formatter arguments statics instead of repeated dynamic #40425

Merged
merged 4 commits into from
Mar 14, 2021

Conversation

attack68
Copy link
Contributor

@attack68 attack68 commented Mar 14, 2021

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  
====== ============ ============

@simonjayhawkins simonjayhawkins added Performance Memory or execution speed performance Styler conditional formatting using DataFrame.style labels Mar 14, 2021
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just a question on the whatsnew

doc/source/whatsnew/v1.3.0.rst Show resolved Hide resolved
@jreback jreback added this to the 1.3 milestone Mar 14, 2021
@jreback jreback merged commit cd5f15d into pandas-dev:master Mar 14, 2021
@jreback
Copy link
Contributor

jreback commented Mar 14, 2021

thanks @attack68

@attack68 attack68 deleted the perf_default_formatter branch March 15, 2021 14:27
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance Styler conditional formatting using DataFrame.style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants