用C语言编写的Python扩展模块比用纯Python编写的等效程序更快.这些扩展模块如何与纯C编写的程序进行比较(速度方面)?用纯C编写的程序是否比同等的Python扩展模块更快?
我正在用C++实现二进制搜索算法,但算法没有返回正确的值.代码可以在这里找到.
template<class T>
int binary_search(T search_value, T search_array[]) {
int mid; /* The middle element of the remaining array to be searched. */
int min = 0; /* The first index of the array. */
/* This forumla gives us the size of the array. */
int max = sizeof(search_array)/sizeof(search_array[0]);
/* Continue searching until min >= max. */
while (min < max) {
/* Compute the value of mid using a formula that won't produce a number
* …Run Code Online (Sandbox Code Playgroud)