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 exarkun
Recipients
Date 2004-12-18.20:20:02
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=366566

I wonder why NNTP_SSL.getline() uses a regular expression to
find a newline.  Wouldn't it be simpler and more efficient
to rewrite the method like this (untested, but I bet it
works, and hopefully it gets the idea across anyway):

|  def getline(self):
|      newline = self.buffer.find('\n')
|      while newline == -1:
|          self._fillBuffer()
|          newline = self.buffer.find('\n')
|      line = self.buffer[:newline]
|      self.buffer = self.buffer[newline + 1:]
|      if line.endswith('\r'):
|          line = line[:-1]
|      return line

Also, wouldn't it be nice if the line handling code here
weren't a duplicate of the line handling code in at least
two other stdlib modules?  I don't mean to single out this
patch, but maybe instead of compounding the problem, this
could be taken as an opportunity to reduce the code
duplication in this area by doing some refactoring of the
various line-based protocol implementations to share code
for this common requirement.
History
Date User Action Args
2007-08-23 15:40:20adminlinkissue1053365 messages
2007-08-23 15:40:20admincreate