SSE4a与python中的ctypes? (gcc __builtin_popcount)
这是示例代码
static inline int distance(unsigned x, unsigned y)
{
return __builtin_popcount(x^y);
}
是否可以使用 ctypes 在 python 中重写上面的 gcc 代码 (最好兼容 Win/*nix)?
蒂亚!
Here is the sample code
Efficiently find binary strings with low Hamming distance in large set
static inline int distance(unsigned x, unsigned y)
{
return __builtin_popcount(x^y);
}
Is it possible to rewrite the above gcc code in python using ctypes
(preferably Win/*nix compatible)?
TIA!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
gmpy 库可以计算两个整数之间的汉明距离。尽管它可能比您需要的更通用,但它比通过 ctypes 调用代码更快。
免责声明:我维护 gmpy。
The gmpy library can calculate the Hamming distance between two integers. Even though it may be more general than you require, it will be faster than calling code via ctypes.
Disclaimer: I maintain gmpy.