enhancement/patch 6x improvement on localize

Bug #493386 reported by nickg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pytz
New
Medium
Unassigned

Bug Description

[Not a bug]

I do a *a lot* of timezone conversions in one particular app, so I was looking for ways to speed up localize.

The following attachment gives an alternate version of localize that is somewhere between 5-7x faster. It passes all tests except for 9 (out of 152430) from the zdump.out. All the hand crafted and doc tests pass.

# FAIL: test_local_to_utc_1941_08_24_23_00_00_dst (__main__.Europe_Zaporozhye)
# FAIL: test_local_to_utc_1941_06_23_23_00_00_dst (__main__.Europe_Vilnius)
# FAIL: test_local_to_utc_1941_09_14_23_00_00_dst (__main__.Europe_Tallinn)
# FAIL: test_local_to_utc_1941_10_31_23_00_00_dst (__main__.Europe_Simferopol)
# FAIL: test_local_to_utc_1941_06_30_23_00_00_dst (__main__.Europe_Riga)
# FAIL: test_local_to_utc_1941_06_27_23_00_00_dst (__main__.Europe_Minsk)
# FAIL: test_local_to_utc_1941_09_19_23_00_00_dst (__main__.Europe_Kiev)
# FAIL: test_local_to_utc_1964_12_31_21_00_00_dst (__main__.Antarctica_Palmer)
# FAIL: test_local_to_utc_1942_07_31_20_00_00_dst (__main__.America_Iqaluit)

I can't figure why these are failing. Using old and new versions of localize I get the same results, so the test
must be doing something slightly more interesting, that I'm not exactly sure of.

The new algorithm IMHO is bit more straight forward than the existing, but I welcome your feedback, especially concerning why those 9 test cases are so special!

If you are interesting in including it in a release, I can swap the license/copyright as need be. It also works just fine as standalone function, so if you don't want replace your existing implementation, it could live in a new file such as "tzutil.py" or something.

thoughts welcome.

--nickg

Revision history for this message
nickg (nickg) wrote :
Stuart Bishop (stub)
Changed in pytz:
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.