Author rhettinger
Recipients barry, jader.fabiano, r.david.murray, rhettinger, serhiy.storchaka, tshepang
Date 2014-08-03.23:03:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1407107012.44.0.57152003558.issue21448@psf.upfronthosting.co.za>
In-reply-to
Content
A deque is typically the right data structure when you need to append, pop, and extend on both the left and right side.  It is designed specifically for that task.  Also, it nicely cleans-up the code by removing the backwards line list and the list reversal prior to insertion on the left (that's what we had to do to achieve decent performance before the introduction of deques in Python 2.4, now you hardly ever see code like "self._lines[:0] = lines[::-1]").  I think fix_prepending2 would be a nice improvement for Py3.5.

For the main patches that directly address the OP's performance issue, feel free to apply either my or yours.  They both work.  Either way, please add test_parser.diff since the original test didn't cover all the cases and because it didn't make clear the relationship between push() and splitlines().
History
Date User Action Args
2014-08-03 23:03:32rhettingersetrecipients: + rhettinger, barry, r.david.murray, tshepang, serhiy.storchaka, jader.fabiano
2014-08-03 23:03:32rhettingersetmessageid: <1407107012.44.0.57152003558.issue21448@psf.upfronthosting.co.za>
2014-08-03 23:03:32rhettingerlinkissue21448 messages
2014-08-03 23:03:32rhettingercreate