This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cython | |
from cpython cimport array | |
from cpython.ref cimport PyObject | |
cdef class addend_ptrwrapper: | |
cdef PyObject* obj | |
cdef bint nonzero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cython: language_level=3 | |
import cython, random, array, timeit | |
test_floats = [*range(10000)] | |
test_tuples = [(i,) for i in range(10000)] | |
test_switches = array.array('i', [random.randint(0,1) for i in range(10000)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# distutils: language = c++ | |
import cython | |
def no_overhead(var): | |
# ~55ns | |
return 0 | |
def py_overhead(var): | |
# ~60ns | |
if isinstance(var, float): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# distutils: language = c++ | |
import cython | |
ctypedef fused fused_type_ohtest: | |
double | |
int | |
ctypedef fused fused_type_ohtest2: | |
double | |
int |