~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_bencode_pyx.pyx

  • Committer: John Arbash Meinel
  • Date: 2009-06-04 16:06:44 UTC
  • mto: This revision was merged to the branch mainline in revision 4410.
  • Revision ID: john@arbash-meinel.com-20090604160644-gtr5g8vsr9ufvvb3
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.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    int Py_EnterRecursiveCall(char *)
38
38
    void Py_LeaveRecursiveCall()
39
39
 
 
40
    int PyList_Append(object, object) except -1
 
41
 
40
42
cdef extern from "stdlib.h":
41
43
    void free(void *memblock)
42
44
    void *malloc(size_t size)
175
177
                else:
176
178
                    return result
177
179
            else:
178
 
                result.append(self._decode_object())
 
180
                PyList_Append(result, self._decode_object())
179
181
 
180
182
        raise ValueError('malformed list')
181
183