简体   繁体   中英

PYTZ takes too long to load

I'm a newbie on Python and I can't find an answer by searching (maybe I'm looking for the wrong search string!).

Using PYTZ on my Raspberry Pi makes a short script (~2000 lines) go from around 5 seconds to around 2 minutes.

I'm sure it's something stupid on my part but are there any fixes out there?

I'm getting to the point of ditching PYTZ altogether but I'm also a bit too far embedded in it (around 15 scripts already use it).

Thanks in advance.

Edit: Here's an extract from my script:

import pytz

#Lots of code

 # Timezone stuff 
localTZ = pytz.timezone('Australia/Sydney') 
nowUTC = datetime.utcnow() currentTime = 
localTZ.localize(nowUTC)

Thanks @mikko-ohtamaa - it I ran the profler and from what I could see that was the problem.

I recalled seeing some things on stackoverflow and elsewhere about PYTZ being available as a binary or interpreted but I couldn't find the info again. I also saw references to libraries existing in two places conflicting too (eg a .egg file and somewhere else).

I uninstalled PYTZ from my python library and reinstalled it... performance problem solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM