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: fix regression in tz_convert_from_utc #38074

Merged
merged 1 commit into from
Nov 26, 2020

Conversation

lidavidm
Copy link
Contributor

Get rid of an unnecessary copy.

@lidavidm
Copy link
Contributor Author

Benchmark after:

[100.00%] ··· ========= ======================= ===================================================== ================================================== ========================================== =============
              --                                                                                                    tz                                                                                           
              --------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                 size    datetime.timezone.utc   datetime.timezone(datetime.timedelta(seconds=3600))   <DstTzInfo 'US/Pacific' LMT-1 day, 16:07:00 STD>   tzfile('/usr/share/zoneinfo/Asia/Tokyo')    tzlocal()  
              ========= ======================= ===================================================== ================================================== ========================================== =============
                  0           2.04±0.01μs                            2.03±0.02μs                                         2.08±0.02μs                                    2.14±0.05μs                  2.04±0.01μs 
                  1           2.06±0.01μs                            8.99±0.07μs                                          7.74±0.1μs                                    8.13±0.07μs                   47.7±0.3μs 
                 100          2.08±0.02μs                            8.99±0.03μs                                         8.79±0.03μs                                    8.70±0.06μs                  4.08±0.04ms 
                10000         3.83±0.06μs                             17.5±0.8μs                                           108±2μs                                       73.7±0.7μs                    404±2ms   
               1000000        1.93±0.03ms                             5.75±0.7ms                                          19.9±0.3ms                                      16.6±1ms                     463±8ns   
              ========= ======================= ===================================================== ================================================== ========================================== =============

Benchmark on master:

[100.00%] ··· ========= ======================= ===================================================== ================================================== ========================================== =============
              --                                                                                                    tz                                                                                           
              --------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                 size    datetime.timezone.utc   datetime.timezone(datetime.timedelta(seconds=3600))   <DstTzInfo 'US/Pacific' LMT-1 day, 16:07:00 STD>   tzfile('/usr/share/zoneinfo/Asia/Tokyo')    tzlocal()  
              ========= ======================= ===================================================== ================================================== ========================================== =============
                  0           2.12±0.06μs                            2.07±0.03μs                                         2.06±0.01μs                                    2.09±0.01μs                  2.02±0.02μs 
                  1           2.10±0.06μs                             8.82±0.2μs                                         7.81±0.07μs                                    8.06±0.07μs                   47.2±0.2μs 
                 100          2.09±0.04μs                             8.98±0.2μs                                         8.88±0.03μs                                    8.79±0.06μs                  4.14±0.08ms 
                10000         3.86±0.04μs                             17.3±0.1μs                                          105±0.1μs                                      73.9±0.1μs                    396±3ms   
               1000000         2.45±0.4ms                             5.58±0.9ms                                          18.8±0.5ms                                     15.5±0.4ms                    437±6ns   
              ========= ======================= ===================================================== ================================================== ========================================== =============

@jreback jreback added Performance Memory or execution speed performance Timezones Timezone data dtype labels Nov 25, 2020
@jreback jreback added this to the 1.2 milestone Nov 25, 2020
@jreback
Copy link
Contributor

jreback commented Nov 25, 2020

lgtm ping on green.

cc @jbrockmendel

@jbrockmendel
Copy link
Member

it isn't obvious to me that the copy is unnecessary

@jorisvandenbossche
Copy link
Member

it isn't obvious to me that the copy is unnecessary

The private method (where the copy is removed), is only called from tz_convert_from_utc just above (python wrapper of the cdef function), and this does a np.array(converted, dtype=np.int64), which will ensure the result is copied anyway.

So I think removing the copy in the private method is fine (it was also like this before)

@jbrockmendel
Copy link
Member

makes sense, thanks

@jreback jreback merged commit 92586ba into pandas-dev:master Nov 26, 2020
@jreback
Copy link
Contributor

jreback commented Nov 26, 2020

thanks @lidavidm

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 Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance regression in tslibs.tz_convert.TimeTZConvert.time_tz_convert_from_utc
4 participants