Created
March 26, 2020 06:04
-
-
Save will-ca/ad1d1ed9bd9ec3ec9ce14553a7487690 to your computer and use it in GitHub Desktop.
Quick test of the speed difference between `object` and `PyObject*` for frequently re-created `cdef` attributes.
This file contains hidden or 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 | |
@cython.locals(s=cython.double, i=addend_ptrwrapper) | |
cpdef double add_ptrwrapped_floats(list seq) | |
@cython.locals(s=cython.int, i=addend_ptrwrapper) | |
cpdef int add_ptrwrapped_tuples(list seq) | |
cdef class addend_objwrapper: | |
cdef object obj | |
cdef bint nonzero | |
@cython.locals(s=cython.double, i=addend_objwrapper) | |
cpdef double add_objwrapped_floats(list seq) | |
@cython.locals(s=cython.int, i=addend_objwrapper) | |
cpdef int add_objwrapped_tuples(list seq) | |
@cython.locals(outseq=list, i=cython.int, w=addend_ptrwrapper) | |
cpdef list get_ptrtest_seq(list seq, bint getseq=*) | |
@cython.locals(outseq=list, i=cython.int, w=addend_objwrapper) | |
cpdef list get_objtest_seq(list seq, bint getseq=*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment