Python 3.1.3 打开 mbox 文件,与 python 2.x 相比真的很慢吗? [英] Python 3.1.3 open mbox file, really slow compared to python 2.x?

查看:46
本文介绍了Python 3.1.3 打开 mbox 文件,与 python 2.x 相比真的很慢吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 python 3.1.3 中打开一个带有邮箱模块的 mbox 文件.里面只有3封邮件,只有27k大.

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.

但是在阅读邮件时,我的 CPU 使用 100% 大约 2-3 分钟,直到它完成任务而没有错误.

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

我在 python 2.7.1 上也尝试过,只需要 1-2 秒?!

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

是我发现了错误还是我做错了什么?我也在 windows 和 linux 上测试过,结果相同:(.

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)

推荐答案

是的,这是一个错误.http://bugs.python.org/issue9124

这篇关于Python 3.1.3 打开 mbox 文件,与 python 2.x 相比真的很慢吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆