thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Jensen (JIRA)" <>
Subject [jira] [Created] (THRIFT-4007) Micro-optimization of
Date Thu, 15 Dec 2016 20:41:58 GMT
Nathan Jensen created THRIFT-4007:

             Summary: Micro-optimization of
                 Key: THRIFT-4007
             Project: Thrift
          Issue Type: Improvement
          Components: Python - Library
            Reporter: Nathan Jensen
            Priority: Trivial

Method readAll(self, sz) in class TTransportBase in can be optimized to only
call len(chunk) once.  It currently calls len(chunk) twice, i.e.

def readAll(self, sz):
    buff = b''
    have = 0
    while (have < sz):
        chunk = - have)     
        have += len(chunk)

        buff += chunk

        if len(chunk) == 0:
            raise EOFError()

    return buff

That results in two method invocations to len(chunk) but it can be reduced to one method invocation
to len(chunk).  Depending on the amount of data being read, the extra len(chunk) method invocations
can add up to slightly slower performance.

This message was sent by Atlassian JIRA

View raw message