Ask Your Question

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

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

greatpet gravatar image

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

I'm looking at Sage developer guide for Cython:

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

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

vdelecroix gravatar image

Cython has a nice documentation, check their project

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


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

Seen: 34 times

Last updated: Apr 10