You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/12/15 20:59:58 UTC

[jira] [Commented] (THRIFT-4007) Micro-optimization of TTransport.py

    [ https://issues.apache.org/jira/browse/THRIFT-4007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15752498#comment-15752498 ] 

ASF GitHub Bot commented on THRIFT-4007:
----------------------------------------

Github user ndjensen commented on the issue:

    https://github.com/apache/thrift/pull/1121
  
    Sorry for the delay.  https://issues.apache.org/jira/browse/THRIFT-4007


> Micro-optimization of TTransport.py
> -----------------------------------
>
>                 Key: THRIFT-4007
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4007
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Python - Library
>            Reporter: Nathan Jensen
>            Priority: Trivial
>              Labels: easyfix, performance
>
> Method readAll(self, sz) in class TTransportBase in TTransport.py can be optimized to only call len(chunk) once.  It currently calls len(chunk) twice, i.e.
> {code}
> def readAll(self, sz):
>     buff = b''
>     have = 0
>     while (have < sz):
>         chunk = self.read(sz - have)     
>         have += len(chunk)
>         buff += chunk
>         if len(chunk) == 0:
>             raise EOFError()
>     return buff
> {code}
> 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
(v6.3.4#6332)