Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.straub-nv.de!news2.arglkargh.de!news.wiretrip.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'python.': 0.05; 'chunk': 0.07; 'imports': 0.07; 'received:209.85.160.174': 0.09; 'received :mail-gy0-f174.google.com': 0.09; 'brandon': 0.16; 'chunks': 0.16; 'splits': 0.16; 'compiled': 0.18; 'wondering': 0.19; 'trying': 0.23; 'appears': 0.24; "i'm": 0.26; 'function': 0.27; 'received:209.85.160': 0.28; 'message-id:@gmail.com': 0.30; 'received:192.168.1.100': 0.31; 'however,': 0.31; 'import': 0.32; 'to:addr:python-list': 0.32; 'expression': 0.33; 'created': 0.33; 'using': 0.34; 'received:192.168.1': 0.34; 'received:192': 0.34; 'regular': 0.34; 'there': 0.35; 'message.': 0.35; 'header:User- Agent:1': 0.35; 'module.': 0.35; 'list,': 0.36; 'received:192.168': 0.37; 'some': 0.37; 'received:209.85': 0.37; 'be,': 0.38; 'faster': 0.38; 'received:google.com': 0.38; 'database': 0.38; 'errors': 0.39; 'to:addr:python.org': 0.39; 'where': 0.39; 'received:209': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'messages': 0.40; 'mailbox': 0.61; 'reads': 0.65; 'thousands': 0.69; 'mailboxes': 0.84; 'subject:Huge': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:x-enigmail-version:content-type:content-transfer-encoding; bh=6i34EFbKt2F5g8TOpUrOhB9pw5b5D7qNeqCogF5zBSo=; b=Je9nkIMtbKe1mo7vGzW0+ocNHqjDLALYfdEzrvIgAzZBW29L5OcSd5NSHXVKBliyLc TXTpilE5cpYQkcHamA3Sk2LPqVQSBbqYrg4C7iiQV8H86krxcwPcbDvZaABBuce6cUhX 3idVH7n+TbyAGJup1B4HqWtPiPJESuJL/AbJw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type:content-transfer-encoding; b=RMW90gIt84LZ5i5F7pwMfecRAoVydVD9ffzloU6fepUAKcccGlyl0fZ8WJsIARyoFz Xjut3Bjwn6VBxr2l+wgvniC3fEEJKH8lvZt2YbRTvoicU6Ss4I6F3LWzsN2ZeILz+C1E ToagnBHXsI8hEgIZr1yNl/cyFHx/uj47l6CfY= Date: Tue, 26 Apr 2011 15:39:37 -0400 From: Brandon McGinty User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: python-list@python.org Subject: Reading Huge UnixMailbox Files X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 14 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303846802 news.xs4all.nl 81474 [::ffff:82.94.164.166]:34480 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4072 List, I'm trying to import hundreds of thousands of e-mail messages into a database with Python. However, some of these mailboxes are so large that they are giving errors when being read with the standard mailbox module. I created a buffered reader, that reads chunks of the mailbox, splits them using the re.split function with a compiled regexp, and imports each chunk as a message. The regular expression work is where the bottle-neck appears to be, based on timings. I'm wondering if there is a faster way to do this, or some other method that you all would recommend. Brandon McGinty