Rev 4410: One of the biggest wins to date, use PyList_Append directly. in lp:///~jameinel/bzr/bencode_serializer

John Arbash Meinel john at arbash-meinel.com
Thu Jun 4 17:07:02 BST 2009


At lp:///~jameinel/bzr/bencode_serializer

------------------------------------------------------------
revno: 4410
revision-id: john at arbash-meinel.com-20090604160644-gtr5g8vsr9ufvvb3
parent: john at arbash-meinel.com-20090604160313-mo66r0hhgkg6vzil
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bencode_serializer
timestamp: Thu 2009-06-04 11:06:44 -0500
message:
  One of the biggest wins to date, use PyList_Append directly.
  
  Our primary data structure is a List, so optimizing this case helps a lot.
  The main win is avoiding all of the generic function calls to append items
  to the current list.
  
  Note that if we required Pyrex 0.9.8+ we could use:
  cdef list result
  result = []
  result.append()
  and wouldn't have to define the PyList_Append functionality manually.
-------------- next part --------------
=== modified file 'bzrlib/_bencode_pyx.pyx'
--- a/bzrlib/_bencode_pyx.pyx	2009-06-04 16:03:13 +0000
+++ b/bzrlib/_bencode_pyx.pyx	2009-06-04 16:06:44 +0000
@@ -37,6 +37,8 @@
     int Py_EnterRecursiveCall(char *)
     void Py_LeaveRecursiveCall()
 
+    int PyList_Append(object, object) except -1
+
 cdef extern from "stdlib.h":
     void free(void *memblock)
     void *malloc(size_t size)
@@ -175,7 +177,7 @@
                 else:
                     return result
             else:
-                result.append(self._decode_object())
+                PyList_Append(result, self._decode_object())
 
         raise ValueError('malformed list')
 



More information about the bazaar-commits mailing list