开发者

Python3 mailbox module is very slow (only mbox?) [duplicate]

开发者 https://www.devze.com 2023-02-04 17:57 出处:网络
This question already has an answer here: Python 3.1.3 open mbox file, really slow compared to python 2.x?
This question already has an answer here: Python 3.1.3 open mbox file, really slow compared to python 2.x? (1 answer) Closed 9 years ago.

I tried in python 3.1.3 to open an mbox file, with the mailbox modu开发者_如何学编程le. 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?

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)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号