Reputation: 147
I prefer a dynamic language like python as it has easier syntax than strongly typed languages like c++
I will be writing code that extensively uses win32 api and my question is whether ctypes differ from c++ when calling winapi in terms of performance and execution speed.
Upvotes: 0
Views: 615
Reputation: 177461
Pure Python code is not as fast as C++. If you are planning on extensively using the Win32 API, converting from Python types to C types and back again frequently is expensive compared to using C++ with the Win32 API directly.
You should also look into pywin32, a library that exposes most of the Win32 API to Python. As @eryksun mentions in the comments below, using straight ctypes means having to write wrappers for C functions, definitions for structures, and context managers for resources, which is prone to error. Pywin32 alleviates that for the commonly used Win32 APIs, but it doesn't contain them all.
Upvotes: 2