【发布时间】:2015-02-19 07:56:53
【问题描述】:
在我的 64 位计算机上,long long 类型有 64 位。
print(sizeof(long long))
# prints 8
我需要使用 128 位整数,幸运的是 GCC supports these。如何在 Cython 中使用这些?
以下不起作用。编译 foo.pyx 只包含
cdef __int128_t x = 0
产量
$ cython foo.pyx
Error compiling Cython file:
------------------------------------------------------------
...
cdef __int128_t x = 0
^
------------------------------------------------------------
foo.pyx:2:5: '__int128_t' is not a type identifier
【问题讨论】:
-
@BrettHale 我不能只输入
cdef __int128_t x = 0。它无法编译。 -
在这种情况下,
cdef到底是什么? -
显然不清楚这个问题是关于 cython 的,尽管它在标题中说。
-
@iharob 出于同样的原因,一个也不会有 64 位 int,因为 python 也没有这些。在 python 中,整数是任意大小的。
-
@iharob 问题不是关于 python,而是关于 cython。您可以在 cython 中使用各种 C 结构/类型,而无需在 python 中公开/使用它们。
标签: c gcc cython long-integer int128