Python 3.1.3 open mbox file, really slow compared to python 2.x?

假装没事ソ 提交于 2019-12-20 03:41:30

问题


I tried in python 3.1.3 to open an mbox file, with the mailbox module. There are only 3 mails in it and it is only 27k big.

But when reading the mails my CPU uses 100% for about 2-3 minutes, until it completes it task without an error.

I tried the same with python 2.7.1 and it takes only about 1-2 seconds?!

Did I found ah bug or I'm doing something wrong? I also tested this on windows and linux, same results :(.

Here's the code I used, from the docs:

import mailbox
for message in mailbox.mbox('~/mbox'):
    subject = message['subject']       # Could possibly be None.
    if subject and 'python' in subject.lower():
        print(subject)

回答1:


Yes, it's a bug. http://bugs.python.org/issue9124



来源:https://stackoverflow.com/questions/4666786/python-3-1-3-open-mbox-file-really-slow-compared-to-python-2-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!