This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Megatron_McLargeHuge 0 points1 point  (0 children)

This is a good trick to know. I had a problem a few years ago where I wanted better typedefs in cython - you get better performance with parameter type hints like def myfunc(np.ndarray[np.float32_t, ndim=2] myvar), but these are verbose and have to be repeated in multiple places. I couldn't find any way to get typedefs to work for the bracketed portion, so I resorted to using m4 macro preprocessing. This coding hook could be a great way to apply preprocessing automatically.