Mason Baran
Mason Baran

Reputation: 67

Cython cdef statement

I am working through some code and have come across this:

cdef:
    float [::1] embed, feats, doc_embed, mention_embed, best_score
    float [:, ::1] s_inp, p_inp

Could someone kindly explain what is being declared here? I am not quite sure if this is a python Slice or a C language specific thing. Please let me know if I can provide any other information.

Upvotes: 0

Views: 158

Answers (1)

ngoldbaum
ngoldbaum

Reputation: 5580

These are definitions for 1D and 2D typed memoryviews. You can think of them as being numpy arrays. It's generally preferred to use memoryviews these days instead of numpy arrays directly because using memoryviews lets cython generate more efficient code.

Upvotes: 3

Related Questions