title: why BitBlt() is slower in python compared to C++?
body: <p>I am trying to use <code>BitBlt()</code> function to copy the bitmap data.</p>
  
  <p>When I use the python <code>win32ui/win32gui</code> <code>API</code> the average time it takes is coming around 30 ms, while the same <code>API</code> when I call using C++, the average time comes around 10-15 ms. </p>
  
  <p>So I am wondering, what could be the reason for the this behavior?</p>
  
  <p>Thanks</p>
  
  <p>EDIT : Here is the snippet :</p>
  
  <p>python :    </p>
  
  <pre><code>hdesktop = win32gui.GetDesktopWindow()
  
  # create a device context
  desktop_dc = win32gui.GetWindowDC(hdesktop)
  img_dc = win32ui.CreateDCFromHandle(desktop_dc)
  
  # create a memory based device context
  mem_dc = img_dc.CreateCompatibleDC()
  
  # create a bitmap object
  screenshot = win32ui.CreateBitmap()
  screenshot.CreateCompatibleBitmap(img_dc, width, height)
  oldbmp = mem_dc.SelectObject(screenshot)
  
  
  # copy the screen into our memory device context
  mem_dc.BitBlt((destUpLeftX, destUpLeftY), (width, height), img_dc, (srcUpLeftX, srcUpLeftY),win32con.SRCCOPY)
  
  mem_dc.SelectObject(oldbmp)
  
  win32gui.DeleteObject(screenshot.GetHandle())
  img_dc.DeleteDC()
  win32gui.ReleaseDC(hdesktop, desktop_dc)
  mem_dc.DeleteDC() 
  </code></pre>
  
  <p>C++ :</p>
  
  <pre><code>HDC hwindowDC=GetDC(GetDesktopWindow());
  HDC hwindowCompatibleDC=CreateCompatibleDC(hwindowDC);
  
  
  // create a bitmap
  HBITMAP hbwindow = CreateCompatibleBitmap( hwindowDC, width, height);
  LOG(LOG_DBG, "before SelectObject");
  
  // SAVE OLD BITMAP
  HGDIOBJ hOldBmp = SelectObject(hwindowCompatibleDC, hbwindow); //copy from hwindowCompatibleDC to hbwindow
  
  
  BitBlt(hwindowCompatibleDC, destUpLeftX, destUpLeftY, width, height, hwindowDC, srcUpLeftX, srcUpLeftY, SRCCOPY);
  
  SelectObject(hwindowCompatibleDC, hOldBmp);
  DeleteDC(hwindowCompatibleDC); 
  DeleteObject(hbwindow);
  
  // RELEASE WINDOW DC
  ReleaseDC(GetDesktopWindow(), hwindowDC);
  </code></pre>