This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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 <>
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().
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: <>
2014-08-03 23:03:32rhettingerlinkissue21448 messages
2014-08-03 23:03:32rhettingercreate