简体   繁体   English

PYTZ加载时间太长

[英]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!). 我是Python的新手,无法通过搜索找到答案(也许我正在寻找错误的搜索字符串!)。

Using PYTZ on my Raspberry Pi makes a short script (~2000 lines) go from around 5 seconds to around 2 minutes. 在我的Raspberry Pi上使用PYTZ可以使简短的脚本(约2000行)从大约5秒变为大约2分钟。

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). 我已经完全放弃了PYTZ,但是我在其中嵌入的位置也有点太远了(大约有15个脚本已在使用它)。

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. 谢谢@ mikko-ohtamaa-我运行了profler,从中可以看出是问题所在。

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. 我回想起在stackoverflow和其他地方看到的有关PYTZ的某些信息可以作为二进制文件或解释文件使用,但我再也找不到该信息。 I also saw references to libraries existing in two places conflicting too (eg a .egg file and somewhere else). 我还看到对两个地方存在的库的引用也存在冲突(例如.egg文件和其他地方)。

I uninstalled PYTZ from my python library and reinstalled it... performance problem solved. 我从python库中卸载了PYTZ,然后重新安装了...性能问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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