[Cython] [ENH] Compile-time code execution (macros / templates)

Prakhar Goel newt0311 at gmail.com
Wed Feb 24 21:37:17 EST 2021


Celelibi,

AST modification is a rare use-case but when you need it, you _really_
need it (speaking from actual experience here)! Think something like
ISPC. Cython already deals with the function AST. Your proposals will
implicitly require rewriting the AST. Why not support it explicitly?
It feels like a small change for a big win (admittedly in only a
limited number of cases). As for debugging, that's up to the person
who wrote the AST rewriting magic.

David,

1. I'm not sure why there would be any dependency on a C compiler in
either mine or Celelibi's proposal. Could you please elaborate? At
least in my proposal, we only ever go from Cython AST to Cython AST
and use Python to do it. None of these things require a C compiler.

2. Again I can't speak for Celelibi but my proposal would be
compile-time only. I'm happy to add restrictions (decorators on cdef
functions only or maybe even special syntax) to ensure that this is
the case.

--
________________________
Warm Regards
Prakhar Goel


More information about the cython-devel mailing list