Ask Your Question
1

Cython / Sage: how to use Static Typing (cdef)?

asked 2021-04-06 13:01:20 +0100

greatpet gravatar image

updated 2021-04-06 13:07:57 +0100

I'm looking at Sage developer guide for Cython: https://doc.sagemath.org/html/en/deve...

But I cannot find information about how to use static typing, which is what enables Cython (not necessarily in the context of Sage) to reach C-like performance. Since objects in Sage often have complicated types (expressions, polynomials), how would type declarations (cdef in Cython) work?

P.S. Does Cython have some type inference capability (like the "auto" keyword in C++) so the user can avoid typing long type names?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-04-10 20:09:45 +0100

vdelecroix gravatar image

Cython has a nice documentation, check their project https://cython.org/

To answer your question

  • There is very few type inference in Cython
  • If your are manipulating Python data, Cython will not help much in getting faster code
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-04-06 13:01:20 +0100

Seen: 330 times

Last updated: Apr 10 '21