How to use the C library "_int128_t.h" in Cython

56 Views Asked by At

In the file .py I use the function:

def xor(block: int, key: int) -> int:
    return block ^ key

To which 128-bit numbers are transmitted.

I want to replace it with a function implemented in Cython. But I can't figure out how to use 128-bit numbers there

I wrote the code:

.pyx

import cython

cdef extern from *:
    ctypedef int int128 "__int128_t"

cpdef int128 xor(int128 block, int128 key):
    return block ^ key

setup.py

from distutils.core import setup
from Cython.Build import cythonize

setup(ext_modules=cythonize('C_code.pyx', language_level="3"))

however, errors occur during compilation.

0

There are 0 best solutions below