Python and STL efficiency

Amanjit Gill amanjit.singh.gill at googlemail.com
Wed Aug 23 17:18:24 EDT 2006


> Hi, I'm learning STL and I wrote some simple code to compare the
> efficiency of python and STL.

Hi, you are benching heap allocations and of course heap fragmentation.
this is what devpartner c++ profiler had to say:

Method       %in % with Called Average Real Name Method Children
-----------------------------------------------------------------
RtlFreeHeap 52,8 52,8 81.034 7,6 7,7
RtlAllocateHeap 19,8 19,8 81.089 2,9 2,9
main 16,9 89,7 1 198083,2 1052376,0
ExitProcess 10,3 10,3 1 120616,8 120641,3
 ...

So on linux its a lot better than that, because - I think - ptmalloc is
used which is based on dmalloc which is efficient for those small size
allocs (which malloc() and free() were never designed for).

on win32, activate the low fragmenting heap or write a custom stl
allocator.

 _set_sbh_threshold(128);   // method 1

  ULONG HeapFragValue = 2;
  HeapSetInformation((HANDLE)_get_heap_handle(),  // method 2
         HeapCompatibilityInformation,
         &HeapFragValue,
         sizeof(HeapFragValue));    

last non-python message from me :)




More information about the Python-list mailing list