[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Minor revisions for python3 performance improvement



commit 2e273a2508b4fd82bce153dde14de476f8750b7b
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat May 23 12:03:29 2015 -0700

    Minor revisions for python3 performance improvement
    
    Just a changelog entry, comment updage, and renaming a variable so it doesn't
    shift it's type (it was fine as-is, just don't like to reuse variables for
    different types like that).
---
 docs/change_log.rst |    1 +
 stem/socket.py      |   13 ++++++-------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index a502dba..edc60ea 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -44,6 +44,7 @@ The following are only available within Stem's `git repository
 
  * **Controller**
 
+  * Dramatic, `300x performance improvement <https://github.com/DonnchaC/stem/pull/1>`_ for reading from the control port with python 3
   * :func:`~stem.connection.connect` and :func:`~stem.control.Controller.from_port` now connect to both port 9051 (relay's default) and 9151 (Tor Browser's default) (:trac:`16075`)
   * Added `support for NETWORK_LIVENESS events <api/response.html#stem.response.events.NetworkLivenessEvent>`_ (:spec:`44aac63`)
 
diff --git a/stem/socket.py b/stem/socket.py
index 637270f..b2b960f 100644
--- a/stem/socket.py
+++ b/stem/socket.py
@@ -587,11 +587,11 @@ def recv_message(control_file):
       # end of the message, return the message
       parsed_content.append((status_code, divider, content))
 
-      raw_content = b''.join(raw_content)
-      log_message = raw_content.replace(b'\r\n', b'\n').rstrip()
+      raw_content_str = b''.join(raw_content)
+      log_message = raw_content_str.replace(b'\r\n', b'\n').rstrip()
       log.trace('Received from tor:\n' + stem.util.str_tools._to_unicode(log_message))
 
-      return stem.response.ControlMessage(parsed_content, raw_content)
+      return stem.response.ControlMessage(parsed_content, raw_content_str)
     elif divider == '+':
       # data entry, all of the following lines belong to the content until we
       # get a line with just a period
@@ -621,12 +621,11 @@ def recv_message(control_file):
         if line.startswith(b'..'):
           line = line[1:]
 
-        # appends to previous content, using a newline rather than CRLF
-        # separator (more conventional for multi-line string content outside
-        # the windows world)
-
         content_lines.append(line)
 
+      # joins the content using a newline rather than CRLF separator (more
+      # conventional for multi-line string content outside the windows world)
+
       parsed_content.append((status_code, divider, b'\n'.join(content_lines)))
     else:
       # this should never be reached due to the prefix regex, but might as well

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits